I am running into an error when trying to pass parameters into a function to define a custom column in my RDataFrame. I am able to use the function if I edit it to work with no input parameters, but run into the following error during make when I try to pass anything in:
make -j4
**Scanning dependencies of target hhbbyy**
[ 8%] Building CXX object CMakeFiles/hhbbyy.dir/src/OverlapDumper.cxx.o
[ 16%] **Linking CXX executable ../run/hhbbyy**
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.30-e5b21/x86_64-centos7/bin/ld: CMakeFiles/hhbbyy.dir/src/OverlapDumper.cxx.o: undefined reference to symbol '_ZN4ROOT6VecOps4RVecIfEC1Ev'
/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBaseExternals/21.2.149/InstallArea/x86_64-centos7-gcc8-opt/lib/libROOTVecOps.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [../run/hhbbyy] Error 1
make[1]: *** [CMakeFiles/hhbbyy.dir/all] Error 2
make: *** [all] Error 2
The following is a simple snippet of what I am trying to do:
Hi @jpearkes,
that is not a compilation error, i.e. your code is fine.
It’s a linker error, so probably there is something missing in your makefile. The missing symbol is _ZN4ROOT6VecOps4RVecIfEC1Ev (which via c++filt demangles to ROOT::VecOps::RVec<float>::RVec()). You are probably not linking libROOTVecOps: maybe just add -lROOTVecOps to the compiler invocation?
Thank you for the speedy reply! I am not 100% sure how to add -lROOTVecOps to the compiler invocation. I tried adding set(CMAKE_CXX_FLAGS “-lROOTVecOps”) to my CMakeLists.txt, but I get the following error when I do that… so I guess it might not be correct. Would it be possible for you to explain in a little more detail?
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.30-e5b21/x86_64-centos7/bin/ld: cannot find -lROOTVecOps
collect2: error: ld returned 1 exit status
I have attached the full CMakeLists.txt just in case it helps.
Ah it’s cmake! I thought it was a plain makefile. Then you add it to target_link_libraries, e.g. target_link_libraries(hhbbyy ${ROOT_LIBRARIES} ROOTVecOps).
Thanks for the quick reply! Deleting everything in my build directory and rerunning cmake and make, I still seem to be getting the same error as before. I’ve double checked that the CMakeLists.txt file was updated with target_link_libraries(hhbbyy ${ROOT_LIBRARIES} ROOTVecOps), and am not sure what to check next.
Updating to target_link_libraries(hhbbyy ${ROOT_LIBRARIES} ROOT::VecOps) results in an error at the cmake step instead of the make one.
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:21 (add_executable):
Target "hhbbyy" links to target "ROOT::VecOps" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
Actually, “-lROOTVecOps” should automatically appear in the output of “root-config --libs” (well, probably unless there is no “veccore” among “root-config --features”) so, it should not be needed to add it again. @Axel If it does not automatically appear also in “ROOT_LIBRARIES” then for me it is a bug in “ROOTConfig.cmake”.
The “make_output.txt” file, present in one of the previous posts above, suggests that “libROOTVecOps” was not present in “ROOT_LIBRARIES” (which originates from “ROOTConfig.cmake”, I guess).
For whatever reason, all ROOT libraries were hardcoded with “-Wl,-rpath,/.../lib” and then adding “-lROOTVecOps” did not work (maybe adding ROOT::ROOTVecOps to target_link_libraries would do the job, though).
Sorry for the slow reply, as mentioned in my first post I am using ROOT 6.20/06. Unfortunately the code isn’t public, which makes things complicated to replicate.
Wile_E_Coyote’s suggestion of adding ROOT::ROOTVecOps to target_link_libraries seems to have worked though! Thanks for the help!