CMakelists.txt找不到-lrt,也找不到-lpthread

时间:2019-12-02 10:36:11

标签: c++ cmake

我要使用激光雷达,其SDK有两个文件夹,分别为"src"includessrc包含很少的CPP文件,而include包含头文件。现在,在我的main.cpp中,我必须导入一个头文件,其中包含使用Lidar所需的所有必要功能。

现在使用CMakelists.txt,我试图添加它们,但显示错误。

====================[ Build | delta_lidar_node | Debug ]========================
"C:\Program Files\JetBrains\CLion 2019.3\bin\cmake\win\bin\cmake.exe" --build C:\Users\kazia\OneDrive\Desktop\cpp\cmake-build-debug --target delta_lidar_node -- -j 2
Scanning dependencies of target delta_lidar_node
[ 50%] Building CXX object CMakeFiles/delta_lidar_node.dir/main.cpp.obj
[100%] Linking CXX executable delta_lidar_node.exe
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lrt
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lpthread
collect2.exe: error: ld returned 1 exit status
CMakeFiles\delta_lidar_node.dir\build.make:85: recipe for target 'delta_lidar_node.exe' failed
CMakeFiles\Makefile2:74: recipe for target 'CMakeFiles/delta_lidar_node.dir/all' failed
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/delta_lidar_node.dir/rule' failed
mingw32-make.exe[3]: *** [delta_lidar_node.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/delta_lidar_node.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/delta_lidar_node.dir/rule] Error 2
mingw32-make.exe: *** [delta_lidar_node] Error 2
Makefile:117: recipe for target 'delta_lidar_node' failed

这是我的Cmakelists.txs

cmake_minimum_required(VERSION 2.8.3)
project(delta_lidar)

set(delta_lidar_SDK_PATH "./src/")

FILE(GLOB delta_lidar_SDK_SRC
        "${delta_lidar_SDK_PATH}/src/*.cpp"
        )

include_directories(
        ${delta_lidar_SDK_PATH}/include
        ${delta_lidar_SDK_PATH}/src
)

add_executable(delta_lidar_node main.cpp ${delta_lidar_SDK_SRC})
target_link_libraries(delta_lidar_node -lrt -lpthread)

enter image description here

0 个答案:

没有答案