Home | News | Documentation | Download

Makefile compilation error

Hello,

I am getting the following error after compiling my makefile.
the Makefile is also attached.
Also the cpp program which has the error is attached.

Thanks

[mansi@localhost RootAnalysis]$ make
g++ -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include   -c -o Correlator.o Correlator.cpp
g++ -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include   -c -o Variables-ddas.o Variables-ddas.cpp
g++ -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include   -c -o AnalyzeDDAS.o AnalyzeDDAS.cpp
rm -f ParametersddasDictionary.cc ParametersddasDictionary.h
rootcint -f ParametersddasDictionary.cxx -c -p Parameters-ddas.h Parametersddas_linkdef.h
warning: Please remove the deprecated flag -c.
warning: Please remove the deprecated flag -p.
Warning: Unused class rule: bdecaySegaTotal
Warning: Unused class rule: bdecaySega
Warning: Unused class rule: bdecaySssdout
Warning: Unused class rule: bdecaySssd
Warning: Unused class rule: bdecayDssdout
Warning: Unused class rule: bdecayTdc
Warning: Unused class rule: bdecayBit
g++ -fPIC -shared -olibParametersddas.so -m64 -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include -I/home/mansi/build_6.20.08/include ParametersddasDictionary.cxx Parameters-ddas.cpp
g++ -Og -o AnalyzeDDAS Correlator.o Variables-ddas.o AnalyzeDDAS.o -L/usr/lib -lpthread -lrt  -lm -L/home/mansi/build_6.20.08/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -pthread -lm -ldl -rdynamic -L -I. -Wl,-rpath,/home/mansi/e17009/60GaBetaDecay/RootAnalysis -L /home/mansi/e17009/60GaBetaDecay/RootAnalysis  -lParametersddas -Wl,-rpath,/usr/opt/ddas/3.0/lib -L /home/mansi/e17009/60GaBetaDecay/RootAnalysis 
/usr/bin/ld: AnalyzeDDAS.o: in function `analyzer(TChain*, TTree*)':
AnalyzeDDAS.cpp:(.text+0xe42): undefined reference to `DDASEvent::DDASEvent()'
/usr/bin/ld: AnalyzeDDAS.cpp:(.text+0xe4e): undefined reference to `DDASEvent::Class()'
/usr/bin/ld: AnalyzeDDAS.cpp:(.text+0x2df9): undefined reference to `typeinfo for DDASEvent'
collect2: error: ld returned 1 exit status
make: *** [Makefile:34: AnalyzeDDAS] Error 1

Makefile.txt (1.4 KB)


ROOT Version: 6.20
Platform: Linux, Fedora
Compiler:
___gcc version 9.2.0 (GCC)
AnalyzeDDAS.cpp (13.5 KB)

thanks.
where should i insert the -c flag ?

Hi @Mansi ,
where is DDASEvent::DDasEvent() defined (in what library or .o file), and is AnalyzeDDAS linked against that file?

Cheers,
Enrico

hello
Yeah, that should be defined in DDASdict.cpp.
which i define using the command,
rootcint -f DDASdict.cpp DDASEvent.h
ddaschannel.h LinkDef.h
DDASdict.cpp (19.3 KB)

Yes, AnalyseDDAS is linked to that file.

Mansi

It doesn’t seem to be? In your original output I don’t see a DDasdict.cpp being passed anywhere.

Anyway when the linker complains that some symbols are undefined like that, typically the solution is to pass the object file (or the source file) that defines them to the compilation command (after the object that needs them, when it comes to linking order matters).

Cheers,
Enrico

I have used the same program before, and it worked with out any errors.
in the current version, I only changed certain classes in the additional cpp codes.
So why I have such a error now ?

I can’t say why or how it worked before, sorry.

When you compile a library or an executable, you have to pass all libraries (or sources) that provide the symbols that the library or executable being compiled requires. Here the linker is complaining that it sees that DDASdict.cpp AnalyzeDDAS.cpp needs the symbol DDASEvent::DDASEvent() (and others) but it’s not present in any of the libraries that are being passed to the compilation command.

If you know that DDASEvent::DDASEvent() is defined in DDASdict.cpp, it should be sufficient to pass that file to the compilation command for AnalyzeDDAS.cpp to fix the linker error.

Those warning are likely relevant. They indicates that either the class are misspelled or that the rootcint/rootcling invocation is missing headers (Currently it sees ‘only’ Parameters-ddas.h and whatever that includes).

Cheers,
Philippe.

Thanks
I removed these unused classes from my Parametersddas_linkdef.h file.
But still i am getting the same error.

make clean
rm -f .o AnalyzeDDAS libParametersddas.so ParametersddasDictionary
[mansi@localhost RootAnalysis]$ make
g++ -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include -c -o Correlator.o Correlator.cpp
g++ -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include -c -o Variables-ddas.o Variables-ddas.cpp
g++ -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include -c -o AnalyzeDDAS.o AnalyzeDDAS.cpp
rm -f ParametersddasDictionary.cxx Parameters-ddasDictionary.h
rootcint -f ParametersddasDictionary.cxx -p Parameters-ddas.h Parametersddas_linkdef.h
warning: Please remove the deprecated flag -p.
g++ -fPIC -shared -olibParametersddas.so -m64 -O3 -I. -I/usr/opt/ddas/3.0/include -pthread -std=c++11 -m64 -I/home/mansi/build_6.20.08/include -I/home/mansi/build_6.20.08/include ParametersddasDictionary.cxx Parameters-ddas.cpp
g++ -O3 -o AnalyzeDDAS Correlator.o Variables-ddas.o AnalyzeDDAS.o -L/usr/lib -lpthread -lrt -lm -L/home/mansi/build_6.20.08/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -pthread -lm -ldl -rdynamic -L -I. -Wl,-rpath,/home/mansi/e17009/60GaBetaDecay/RootAnalysis -L /home/mansi/e17009/60GaBetaDecay/RootAnalysis -lParametersddas -Wl,-rpath,/usr/opt/ddas/3.0/lib -L /home/mansi/e17009/60GaBetaDecay/RootAnalysis
/usr/bin/ld: AnalyzeDDAS.o: in function analyzer(TChain*, TTree*)': AnalyzeDDAS.cpp:(.text+0xe22): undefined reference to DDASEvent::DDASEvent()’
/usr/bin/ld: AnalyzeDDAS.cpp:(.text+0xe2e): undefined reference to DDASEvent::Class()' /usr/bin/ld: AnalyzeDDAS.cpp:(.text+0x2dd9): undefined reference to typeinfo for DDASEvent’
collect2: error: ld returned 1 exit status
make: *** [Makefile:34: AnalyzeDDAS] Error 1

Thanks

I could resolve the problem and can “make” now.
But when i try to sort a data file, I get a error in the end -

[mansi@localhost RootAnalysis]$ ./AnalyzeDDAS 2001
file number 2001

Input file: 	 /home/mansi/e17009/dumpedfiles/run2001-00.root
Output file: 	/home/mansi/e17009/Analysis/test/run-2001_analysis.root

Error in cling::AutoloadingVisitor::InsertIntoAutoloadingState:
   Missing FileEntry for DDASEvent.h
   requested to autoload type ddaschannel
Error in cling::AutoloadingVisitor::InsertIntoAutoloadingState:
   Missing FileEntry for DDASEvent.h
   requested to autoload type DDASEvent
Added file /home/mansi/e17009/dumpedfiles/run2001-00.root to the chain 6572977
Added file /home/mansi/e17009/dumpedfiles/run2001-01.root to the chain 13176307
Added file /home/mansi/e17009/dumpedfiles/run2001-02.root to the chain 19768917
Added file /home/mansi/e17009/dumpedfiles/run2001-03.root to the chain 27472557
Added file /home/mansi/e17009/dumpedfiles/run2001-04.root to the chain 29650361
Error in <TFile::TFile>: file /home/mansi/e17009/dumpedfiles/run2001-05.root does not exist
No more files to add ... moving on
29650361 : No of Entries
Starting correlator...
Reading DSSD calibration from: /home/mansi/e17009/60GaBetaDecay/RootAnalysis/cal/DSSDInit.txt
Reading Other calibration from: /home/mansi/e17009/60GaBetaDecay/RootAnalysis/cal/OtherInit.txt
Reading DSSD calibration from: /home/mansi/e17009/60GaBetaDecay/RootAnalysis/cal/SuNInit.txt
---> Correlation window: 5000 ms
---> Minimplant tdiff: 950 ms
Number events in run segment: 29650361
Events processed 296503 - percent done 1%
Events processed 593006 - percent done 2%
Events processed 889509 - percent done 3%
Events processed 1186012 - percent done 4%
Events processed 1482515 - percent done 5%
Events processed 1779018 - percent done 6%
Events processed 2075521 - percent done 7%
Events processed 2372024 - percent done 8%
Events processed 2668527 - percent done 9%
Events processed 2965030 - percent done 10%
Events processed 3261533 - percent done 11%
Events processed 3558036 - percent done 12%
Events processed 3854539 - percent done 13%
Events processed 4151042 - percent done 14%
Events processed 4447545 - percent done 15%
Events processed 4744048 - percent done 16%
Events processed 5040551 - percent done 17%
Events processed 5337054 - percent done 18%
Events processed 5633557 - percent done 19%
Events processed 5930060 - percent done 20%
Events processed 6226563 - percent done 21%
Events processed 6523066 - percent done 22%
Events processed 6819569 - percent done 23%
Events processed 7116072 - percent done 24%
Events processed 7412575 - percent done 25%
Events processed 7709078 - percent done 26%
Events processed 8005581 - percent done 27%
Events processed 8302084 - percent done 28%
Events processed 8598587 - percent done 29%
Events processed 8895090 - percent done 30%
Events processed 9191593 - percent done 31%
Events processed 9488096 - percent done 32%
Events processed 9784599 - percent done 33%
Events processed 10081102 - percent done 34%
Events processed 10377605 - percent done 35%
Events processed 10674108 - percent done 36%
Events processed 10970611 - percent done 37%
Events processed 11267114 - percent done 38%
Events processed 11563617 - percent done 39%
Events processed 11860120 - percent done 40%
Events processed 12156623 - percent done 41%
Events processed 12453126 - percent done 42%
Events processed 12749629 - percent done 43%
Events processed 13046132 - percent done 44%
Events processed 13342635 - percent done 45%
Events processed 13639138 - percent done 46%
Events processed 13935641 - percent done 47%
Events processed 14232144 - percent done 48%
Events processed 14528647 - percent done 49%
Events processed 14825150 - percent done 50%
Events processed 15121653 - percent done 51%
Events processed 15418156 - percent done 52%
Events processed 15714659 - percent done 53%
Events processed 16011162 - percent done 54%
Events processed 16307665 - percent done 55%
Events processed 16604168 - percent done 56%
Events processed 16900671 - percent done 57%
Events processed 17197174 - percent done 58%
Events processed 17493677 - percent done 59%
Events processed 17790180 - percent done 60%
Events processed 18086683 - percent done 61%
Events processed 18383186 - percent done 62%
Events processed 18679689 - percent done 63%
Events processed 18976192 - percent done 64%
Events processed 19272695 - percent done 65%
Events processed 19569198 - percent done 66%
Events processed 19865701 - percent done 67%
Events processed 20162204 - percent done 68%
Events processed 20458707 - percent done 69%
Events processed 20755210 - percent done 70%
Events processed 21051713 - percent done 71%
Events processed 21348216 - percent done 72%
Events processed 21644719 - percent done 73%
Events processed 21941222 - percent done 74%
Events processed 22237725 - percent done 75%
Events processed 22534228 - percent done 76%
Events processed 22830731 - percent done 77%
Events processed 23127234 - percent done 78%
Events processed 23423737 - percent done 79%
Events processed 23720240 - percent done 80%
Events processed 24016743 - percent done 81%
Events processed 24313246 - percent done 82%
Events processed 24609749 - percent done 83%
Events processed 24906252 - percent done 84%
Events processed 25202755 - percent done 85%
Events processed 25499258 - percent done 86%
Events processed 25795761 - percent done 87%
Events processed 26092264 - percent done 88%
Events processed 26388767 - percent done 89%
Events processed 26685270 - percent done 90%
Events processed 26981773 - percent done 91%
Events processed 27278276 - percent done 92%
Events processed 27574779 - percent done 93%
Events processed 27871282 - percent done 94%
Events processed 28167785 - percent done 95%
Events processed 28464288 - percent done 96%
Events processed 28760791 - percent done 97%
Events processed 29057294 - percent done 98%
Events processed 29353797 - percent done 99%
Events processed 29650300 - percent done 100%

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fe2b4d53d1a in wait4 () from /lib64/libc.so.6
#1  0x00007fe2b4cd092f in do_system () from /lib64/libc.so.6
#2  0x00007fe2b6da23fc in TUnixSystem::StackTrace() () from /home/mansi/build_6.20.08/lib/libCore.so
#3  0x00007fe2b6d9f93c in TUnixSystem::DispatchSignals(ESignals) () from /home/mansi/build_6.20.08/lib/libCore.so
#4  <signal handler called>
#5  0x00007fe2b54bf8a0 in betadecay::~betadecay() () from /home/mansi/e17009/60GaBetaDecay/RootAnalysis/libParametersddas.so
#6  0x000000000040bf7c in analyzer(TChain*, TTree*) ()
#7  0x0000000000405295 in main ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007fe2b54bf8a0 in betadecay::~betadecay() () from /home/mansi/e17009/60GaBetaDecay/RootAnalysis/libParametersddas.so
#6  0x000000000040bf7c in analyzer(TChain*, TTree*) ()
#7  0x0000000000405295 in main ()
=========================================================

Hi,
how did you solve the original linker error?

The current problem is a segmentation fault in betadecay::~betadecay(). That is typically a bug in memory/lifetime management in the user’s code. You can try compiling the application without optimizations (no -O compilation flags) and with debug symbols (-g compilation flag) to get better stacktraces: that will tell you exactly at what line the invalid memory access is happening.
Then you can also run the program within gdb to inspect the state of the program at the time it crashes.

Also please check out Posting code? Read this first! for instructions on how to post code. I edited your previous post to make it more readable.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.