Home | News | Documentation | Download

Undefined symbol with TSpectrum

Hello,

I have a problem when I try to use the TSpectrum class.

I’m using cmake to compile a binary from a code that works fine, but if I declare a variable TSpectrum, I get the following error when I run the macro (cmake and make gives no errors, it compiles fine):

/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/5.34.34/x86_64-cc7-gcc48-opt/root/bin/root.exe: symbol lookup error: ~/WA105_LightSoft/build/lib/libLightSoft.so: undefined symbol: _ZN9TSpectrumC1Eif

And if I do filt:

 bash-4.2$ c++filt -n _ZN9TSpectrumC1Eif
TSpectrum::TSpectrum(int, float)

I think it may be cased by a bad definition of the libraries, but then I don’t understand why I can use all the other ROOT classes without problems (TH, TF…). I don’t know if it is a cmake or ROOT problem…

I attach my CMakeLists.txt

Any help is welcome!

Best regards,
J

CMakeLists.txt (1.8 KB)

1 Like

Hi,

the library does contain the symbol

nm -C /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/5.34.34/x86_64-cc7-gcc48-opt/root/lib/libSpectrum.so |grep "TSpectrum::TSpectrum("
0000000000078e20 T TSpectrum::TSpectrum(int, float)
0000000000078bd0 T TSpectrum::TSpectrum()
0000000000078e20 T TSpectrum::TSpectrum(int, float)
0000000000078bd0 T TSpectrum::TSpectrum()

I think it just needs to be linked and LD_LIBRARY_PATH set correctly.

Cheers,
D

Thanks for your answer dpiparo, but do you know how can I do this?

In the FindROOT.cmake that I’m using, I found:

    ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
       COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE}
       ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE})

And later:

  SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})

I’m new using this, and I am a bit lost, any help is welcome.

FindROOT.cmake.txt (9.4 KB)

Hi,

You’ll need to link with libSpectrum (CMake calls it Spectrum); check the CMake doc on how to add a library to the target of your library / binary. I believe it’s target_link_libraries(LightSoft Spectrum).

Cheers, Axel.

2 Likes

Thank you, Axel. Finally I got it, I just added the line target_link_libraries(LightSoft Spectrum), and it works.

Best regards,
José

1 Like

Good! I updated my post to remove the comma - thanks.

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