0

I want to use a LIDAR and their SDK has two folders which are "src" and includes. src, contain few CPP files whereas include contains the header file. Now in my main.cpp I have to import one header file that contains all the necessary functions to work with the Lidar.

Now using CMakelists.txt I was trying to add them but it shows error.

====================[ 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

here is my 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

Kazi
  • 1,461
  • 3
  • 19
  • 47
  • 2
    Why have you deleted your [previous question](https://stackoverflow.com/questions/59130799/) instead of editing it? And again, please, show **exact error message** as a **text**. The part you have cited - "No such file or directory" is almost useless. Why do not copy-paste the whole output into the question post? – Tsyvarev Dec 02 '19 at 10:47
  • I wanted to be more specific. Related to Cmake only. thanks anyway. And the post is updated @Tsyvarev – Kazi Dec 02 '19 at 10:55
  • Have you tried to google using the error message `cannot find -lpthread`? (Possible googling is one of the reasons to provide the messages as text). See e.g. [this question](https://stackoverflow.com/questions/21827392/cannot-find-lpthread). – Tsyvarev Dec 02 '19 at 11:02
  • Could you also provide make VERBOSE=1 output ? I'm not sure -lpthread and -lrt are valid for target_link_libraries. Have you try "pthread" and "rt" (without -l) ? – Gojita Dec 02 '19 at 13:17

0 Answers0