Linking with CMakeLists: ld cannot find library

前端 未结 2 1870
孤街浪徒
孤街浪徒 2021-01-19 12:25

I have a CMakeLists.txt file, with the following:

target_link_libraries(${PROJECT_NAME} OpenNI2)

When I run cmake

2条回答
  •  旧巷少年郎
    2021-01-19 12:55

    That's because when linking, the linker doesn't look in the current directory but only in a set of predefined directories.

    You need to tell CMake where the library is, for example by giving the full path to the library in the target_link_library command, or adding it as an imported library.

提交回复
热议问题