鏈接到外部庫如何讓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)在我將庫復制到二進制dir之后bin/res.我試著用find_library(RESULT mylib.so PATHS ${CMAKE_BINARY_DIR}/res)卻失敗了RESULT-NOTFOUND.
3 回答

慕斯王
TA貢獻1864條經驗 獲得超2個贊
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/res)
TARGET_LINK_LIBRARIES(GLBall mylib)
添加回答
舉報
0/150
提交
取消