cmakelist.txt文件里面有这么一种语法
target_link_libraries(MY_TARGET LIB1 LIB2 ... LIBN dl rt)
rt表示librt.so, librt.so是glibc中对real-time部分的支持库。所以一般含有#include
dl是libdl.so, 例如dlopen, dlclose就是这个库中函数, 也可以用${CMAKE_DL_LIBS}替换dl:
target_link_libraries(MY_TARGET LIB1 LIB2 ... LIBN ${CMAKE_DL_LIBS} rt)
CMAKE_DL_LIBS¶
Name of library containing dlopen and dlcose.
The name of the library that has dlopen and dlclose in it, usually -ldl on most UNIX machines.