Troubles building an executable

Well, my problem is that I couldn’t compile my own application because I got the errors:

lncms01> gmake -f MakeAnalyzav00
g++ -I/usr/local/root/3.10.02.2952//include -Wall -g -ansi -lm -D_REENTRANT -I/usr/local/root/3.10.02.2952//include -L/usr/local/root/3.10.02.2952//lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -ldl -rdynamic -L/usr/local/root/3.10.02.2952//lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -lpthread -lm -ldl -rdynamic -L-L/usr/local/root/3.10.02.2952//lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -ldl -rdynamic -o Analizav00 AnalizaMainv00.cxx AnalizaGUIv00.cxx
/tmp/ccKIm9Sc.o: In function TQObjSender::SetSenderClassName(char const *)': /usr/local/root/3.10.02.2952/include/TQObject.h(.data+0x0): multiple definition ofmb_button_id’
/tmp/ccB5LWIM.o:/usr/local/root/3.10.02.2952/include/TGClient.h:85: first defined here
/tmp/ccKIm9Sc.o: In function TQObjSender::SetSenderClassName(char const *)': /usr/local/root/3.10.02.2952/include/TQObject.h(.data+0x24): multiple definition ofmb_icon’
/tmp/ccB5LWIM.o:/usr/local/root/3.10.02.2952/include/TGClient.h:85: first defined here
/tmp/ccKIm9Sc.o: In function TQObjSender::SetSenderClassName(char const *)': /usr/local/root/3.10.02.2952/include/TQObject.h(.data+0x34): multiple definition offiletypes’
/tmp/ccB5LWIM.o:/usr/local/root/3.10.02.2952/include/TGClient.h:85: first defined here
/tmp/ccKIm9Sc.o: In function TQObjSender::SetSenderClassName(char const *)': /usr/local/root/3.10.02.2952/include/TQObject.h(.data+0x60): multiple definition ofhisto_data’
/tmp/ccB5LWIM.o:/usr/local/root/3.10.02.2952/include/TGClient.h:85: first defined here
/tmp/ccKIm9Sc.o: In function TQObjSender::SetSenderClassName(char const *)': /usr/local/root/3.10.02.2952/include/TQObject.h(.data+0xc0): multiple definition offunction_data’
/tmp/ccB5LWIM.o:/usr/local/root/3.10.02.2952/include/TGClient.h:85: first defined here
/tmp/ccKIm9Sc.o: In function TQObjSender::SetSenderClassName(char const *)': /usr/local/root/3.10.02.2952/include/TQObject.h(.data+0x100): multiple definition oftree_data’
/tmp/ccB5LWIM.o:/usr/local/root/3.10.02.2952/include/TGClient.h:85: first defined here
/usr/lib/gcc-lib/i386-redhat-linux/2.96/…/…/…/crt1.o: In function _start': /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference tomain’
collect2: ld returned 1 exit status
gmake: *** [Analizav00] Error 1
lncms01>

My makefile … is :

-------------------------------------------------------------------------------

– Project: Telescópio de Raios Cósmicos

– MAKEFILE FOR ANALIZA (Version 00) - Build 2004.05.03

– This program analysis the data files from Labview.

– Author: João Pires (jpires@lip.pt)

– L.I.P., Laboratorio de Instrumentacao e Fisica Experimental de Particulas

-------------------------------------------------------------------------------

compiler and flags

#ROOTSYS = /usr/local/root/3.10.01.296
C = g++
CFLAGS = -I$(ROOTSYS)/include -Wall -g -ansi
#CLFAGS = -Wall -g -ansi
CLIBS = -lm

root libraries and flags

ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)

#sources and libraries
SRC = AnalizaMainv00.cxx AnalizaGUIv00.cxx #AnalizaAmplitudev00.cxx
LIBS = -L$(ROOTLIBS)

#program
PROGRAM = Analizav00

#create convert target
$(PROGRAM): $(SRC)
$© $(CFLAGS) $(CLIBS) $(ROOTCFLAGS) $(ROOTLIBS) $(ROOTGLIBS) $(LIBS) -o $(PROGRAM) $(SRC)

If some one could help me I’m greatfull

Cheers,

João Pires

Hi,

It seems that you are trying to link code build with gcc 2.95.2 with the version 2.96 of the compiler. Make sure that you always use the same compiler.

Cheers,
Philippe.

Well in fact I had corrected the version of the gcc compiler but the problem presists … I don’t know why …

There’s anybody out there who could help me please?

João Pires

Hi,

Make sure that you recompile everything from scratch with the correct compiler and linkers. Then, if there is still an error, send me the new error output.

Cheers,
Philippe.

Well I try to do that and what I get is the following:

lncms01> gmake -f MakefileAnalizav00
g++ -O AnalizaMainv00.o AnalizaGUIv00.o AnalizaGUIDictv00.o -.L-L/usr/local/root/3.10.01.296/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -lpthread -lm -ldl -rdynamic/lib -o Analizav00
g++: unrecognized option -.L-L/usr/local/root/3.10.01.296/lib' g++: unrecognized option-rdynamic/lib’
AnalizaGUIv00.o(.data+0x0): multiple definition of mb_button_id' AnalizaMainv00.o(.data+0x0): first defined here AnalizaGUIv00.o(.data+0x24): multiple definition ofmb_icon’
AnalizaMainv00.o(.data+0x24): first defined here
AnalizaGUIv00.o(.data+0x34): multiple definition of filetypes' AnalizaMainv00.o(.data+0x34): first defined here AnalizaGUIv00.o(.data+0x60): multiple definition ofhisto_data’
AnalizaMainv00.o(.data+0x60): first defined here
AnalizaGUIv00.o(.data+0xc0): multiple definition of function_data' AnalizaMainv00.o(.data+0xc0): first defined here AnalizaGUIv00.o(.data+0x100): multiple definition oftree_data’
AnalizaMainv00.o(.data+0x100): first defined here
AnalizaGUIDictv00.o(.data+0x0): multiple definition of mb_button_id' AnalizaMainv00.o(.data+0x0): first defined here AnalizaGUIDictv00.o(.data+0x24): multiple definition ofmb_icon’
AnalizaMainv00.o(.data+0x24): first defined here
AnalizaGUIDictv00.o(.data+0x34): multiple definition of filetypes' AnalizaMainv00.o(.data+0x34): first defined here AnalizaGUIDictv00.o(.data+0x60): multiple definition ofhisto_data’
AnalizaMainv00.o(.data+0x60): first defined here
AnalizaGUIDictv00.o(.data+0xc0): multiple definition of function_data' AnalizaMainv00.o(.data+0xc0): first defined here AnalizaGUIDictv00.o(.data+0x100): multiple definition oftree_data’
AnalizaMainv00.o(.data+0x100): first defined here
/usr/bin/ld: cannot find -lCore
collect2: ld returned 1 exit status
gmake: *** [Analizav00] Error 1

When I use another makefile named Makefile … i got:

lncms01> make
make: *** No rule to make target Analizav00LinkDef.h', needed byAnalizaGUIv00Dict.cxx’. Stop.

In attachement I will send the files … if you or soemone else could help me I’ll be very greatfull.

Cheers,

João Pires
Analiza.tar.gz (51.3 KB)

Hi,

The problem is that in your header files you have:

const char *filetypes[] = { //"All files", "*", ....
This is the instantiation of a variable. This means that EACH source file that include this header will create a duplicate of this (hence the linker error).
Instead you should have that statement in a source file and just have something like:

in the header file.
Better yet you should not use global variables …

Cheers,
Philippe.