emilk / loguru

A lightweight C++ logging library
The Unlicense
1.77k stars 256 forks source link

Error linking to libdl.so #175

Open YonatanSimson opened 3 years ago

YonatanSimson commented 3 years ago

I am getting this error message when trying to link loguru:

 /usr/bin/ld: CMakeFiles/feature_tracker_node.dir/src/feature_node.cpp.o: undefined reference to symbol 'dladdr@@GLIBC_2.2.5'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/feature_tracker_node.dir/build.make:125: recipe for target 'feature_tracker_node' failed
make[2]: *** [feature_tracker_node] Error 1
CMakeFiles/Makefile2:141: recipe for target 'CMakeFiles/feature_tracker_node.dir/all' failed
make[1]: *** [CMakeFiles/feature_tracker_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I tried adding to CMAKE_CXX_FLAGS -ldl at the end. This didn't help.

Any ideas?

Nicba1010 commented 3 years ago

Have you tried to target_link_libaries the target with ${CMAKE_DL_LIBS}?

ObjectOops commented 2 months ago

Have you tried to target_link_libaries the target with ${CMAKE_DL_LIBS}?

I had a similar issue and this worked for me.