Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ CMakelists.txt找不到-lrt,也找不到-lpthread_C++_Cmake - Fatal编程技术网

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

C++ CMakelists.txt找不到-lrt,也找不到-lpthread,c++,cmake,C++,Cmake,我想使用激光雷达,他们的SDK有两个文件夹,分别是“src”和includessrc包含少量的CPP文件,而include包含头文件。现在,在我的main.cpp中,我必须导入一个头文件,其中包含使用激光雷达所需的所有功能 现在使用CMakelists.txt,我试图添加它们,但它显示错误 ====================[ Build | delta_lidar_node | Debug ]======================== "C:\Program Files\JetBr

我想使用激光雷达,他们的SDK有两个文件夹,分别是
“src”
includes
src
包含少量的CPP文件,而
include
包含头文件。现在,在我的
main.cpp
中,我必须导入一个头文件,其中包含使用激光雷达所需的所有功能

现在使用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)

您为什么要删除而不是编辑?请再次以文本形式显示准确的错误消息。你提到的“没有这样的文件或目录”几乎是无用的。为什么不将整个输出复制粘贴到问题帖中?我想说得更具体一些。仅与Cmake相关。无论如何,谢谢你。帖子更新为@TsyvarevHave您是否尝试使用错误消息
找不到-lpthread
?(谷歌搜索可能是以文本形式提供信息的原因之一)。请参阅,例如,您是否也可以提供make VERBOSE=1输出?我不确定-lpthread和-lrt对于目标链接库是否有效。你试过“pthread”和“rt”(不带-l)吗?