我用cmake編譯經常遇到一個問題,今天在這裡記錄一下:
undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
解決方法:
加一個 -ldl,将下面這句話加在CMakeLists.txt裡面
set (CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
參考連結:
https://stackoverflow.com/questions/23141575/undefined-reference-to-symbol-dso-missing-from-command-line