如何让CMake将可执行文件链接到不在同一CMake项目中构建的外部共享库?
只是做target_link_libraries(GLBall ${CMAKE_BINARY_DIR}/res/mylib.so)
了错误
make[2]: *** No rule to make target `res/mylib.so', needed by `GLBall'. Stop.
make[1]: *** [CMakeFiles/GLBall.dir/all] Error 2
make: *** [all] Error 2
(GLBall is the executable)
Run Code Online (Sandbox Code Playgroud)
在我将库复制到二进制目录后bin/res
.
我试过用 find_library(RESULT mylib.so PATHS ${CMAKE_BINARY_DIR}/res)
哪个失败了RESULT-NOTFOUND
.
如何将math
库添加到我的CMake文件中?这篇文章引用了添加一个目标链接库,但我对C不太熟悉.附加帖子 - 有人可以举一个例子.文档我正在使用C,我收到了一个undefined reference to 'pow'
带有数学标题的pow方法.
cmake_minimum_required(VERSION 3.3)
project(CSCI-E-28-Unix-Linux-Systems-Programming)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
CMakeLists.txt
getchar.c
main.cpp
hw0
more01.c)
#target_link_libraries(<math.h> m)
add_executable(main main.cpp)
add_executable(getchar getchar.c)
add_executable(more01 more01.c)
add_executable(argu print_all_arguments.c)
add_executable(chars chars.c)
add_executable(ch4 ch4.c)
Run Code Online (Sandbox Code Playgroud)