/usr/bin/ld: CMakeFiles/Eutelescope.dir/eutelescope/libraries/src/EUTelGenericPixGeoMgr.cc.o: in function eutelescope::geo::EUTelGenericPixGeoMgr::addPlane(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': /home/hict/Downloads/eutelescope-2.3/eutelescope/libraries/src/EUTelGenericPixGeoMgr.cc:103: undefined reference to dlopen'
/usr/bin/ld: /home/hict/Downloads/eutelescope-2.3/eutelescope/libraries/src/EUTelGenericPixGeoMgr.cc:112: undefined reference to dlsym' /usr/bin/ld: /home/hict/Downloads/eutelescope-2.3/eutelescope/libraries/src/EUTelGenericPixGeoMgr.cc:106: undefined reference to dlerror'
Assistant
These linker errors are indicating that you're missing the dynamic linking library (libdl), which provides functions like dlopen, dlsym, and dlerror. To fix this issue, you need to link against libdl when compiling your application. Here's how you can do it:
If you are using CMake:
Open your CMakeLists.txt file.
Add the following line to ensure that you link against libdl:
cmake
target_link_libraries(Eutelescope dl)
Make sure to replace Eutelescope with the actual name of your target.
target_link_libraries(Eutelescope dl) tells CMake to link your target Eutelescope with the libdl library.
The libdl library provides functions for dynamic linking (loading shared libraries at runtime), which are causing the undefined reference errors in your compiler output.
After making this change, you should re-run CMake and then build your project again. This should resolve the undefined reference errors related to dlopen, dlsym, and dlerror.
# Assumes CMake 3.13 or above
# Define the executable or library
add_executable(Eutelescope eutelescope/libraries/src/EUTelGenericPixGeoMgr.cc)
# Link against libdl
target_link_libraries(Eutelescope PUBLIC dl)
# eutelescope/libraries/CMakeLists.txt
add_library(Eutelescope STATIC
src/EUTelGenericPixGeoMgr.cc
# Add other source files here
)
target_link_libraries(Eutelescope PUBLIC dl)
These switches activate/deactivate compiler switches such as the
inclusion of debugging symbols and code optimizations. For actual
data analysis we recommend setting CMAKE_BUILD_TYPE to "Release"
while for development "RelWithDebInfo" is best used. For actual
debugging e.g. using gdb, please consider "Debug" which will turn
off all (!) optimizations but will be "gdb-friendlier"
!RELEASE: comment out the following line and comment in either one of the release ones
SET( CMAKE_BUILD_TYPE Debug ) # use for debugging with e.g. gdb: add. warnings, no optimizations, debug symbols
SET( CMAKE_BUILD_TYPE RelWithDebInfo ) # useful for normal development, runs faster but compilation takes longer: gcc optimizations (-O2) with debug symbols and add. warnings
#SET( CMAKE_BUILD_TYPE Release ) # for production: full gcc optimization (-O3), no debug symbols, no debug messages
EUTelescope uses the CMake/CTest framework for daily automated,
#data-driven tests to constantly verify the validity of the output. The
#basis for the tests are the examples provided with the software
#together with a real data sample and the expected output in form of
#root files.
#If you are a user of EUTelescope and you have already taken data and
#performed you analysis, we would be very interested in obtaining a
#data sample with the corresponding analysis results including the
#EUTelescope configuration used so that we can include your analysis in
#the regular testing. This guarantees that your analysis will be well
#supported in future releases of EUTelescope and it might serve as a
#good starting point for others.
#The test can also be used by any developer who wishes to verify
#changes made to the EUTelescope code. For a short how-to see
#README.tests; for more detailed information see the CMake manual or
#web page (http://www.cmake.org/Wiki/CMake/Testing_With_CTest).
IF( NOT DEFINED ENV{EUTELESCOPE} OR NOT DEFINED ENV{MARLIN} )
MESSAGE( "trying to load build and run environment for EUTelescope" )
code
IF( DEFINED ENV{ILCSOFT} )
EXECUTE_PROCESS( COMMAND sh -c " [ -f $ILCSOFT/Eutelscope/trunk/build_env.sh ] && . $ILCSOFT/Eutelescope/trunk/build_env.sh" )
IF( NOT DEFINED ENV{EUTELESCOPE} OR NOT DEFINED ENV{MARLIN} )
# try to load build_env.sh environment - if running 'make' from 'build' directory, it should be located in '../'
EXECUTE_PROCESS( COMMAND sh -c " [ -f '../build_env.sh' ] && . ../build_env.sh" )
IF( DEFINED ENV{EUTELESCOPE} AND DEFINED ENV{MARLIN} )
MESSAGE( "EUTELESCOPE environment automatically loaded from ../build_env.sh" )
ENDIF()
ENDIF()
ENDIF()
configure_file( ./CTestCustom.cmake.in # set custom settings (e.g. tests to be skipped for valgrind)
${PROJECT_BINARY_DIR}/CTestCustom.cmake
)
ELSE()
MESSAGE( "EUTELESCOPE environment variable not defined, cannot run tests
- please run 'source build_env.sh' in the EUTel root directory first." )
ENDIF()