Undefined reference to symbol ‘dlclose@@GLIBC_2.2.5‘ //lib/x86_64-linux-gnu/libdl.so.2

我用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

【Undefined reference to symbol ‘dlclose@@GLIBC_2.2.5‘ //lib/x86_64-linux-gnu/libdl.so.2】解决方法:
加一个 -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

    推荐阅读