[英]Linking ready made external static library
I have a ready made external static library (.a) that I want to link to my executable. 我有一个现成的外部静态库(.a),我想链接到我的可执行文件。 How exactly can I do it with cmake?
我怎么能用cmake做到这一点?
You should use the TARGET_LINK_LIBRARIES
command. 您应该使用
TARGET_LINK_LIBRARIES
命令。 But before that you might want to make sure CMake looks into correct directories by using FIND_LIBRARY
or LINK_DIRECTORIES
. 但在此之前,您可能希望确保CMake使用
FIND_LIBRARY
或LINK_DIRECTORIES
查找正确的目录。 All are documented in detail here: ( CMake help: TARGET_LINK_LIBRARIES ) ( CMake help: LINK_DIRECTORIES ) ( CMake help: FIND_LIBRARY ) 所有内容都在此处详细说明:( CMake帮助:TARGET_LINK_LIBRARIES )( CMake帮助:LINK_DIRECTORIES )( CMake帮助:FIND_LIBRARY )
According to the comment by @Fraser, it is better to use find_library
over link_directories
. 根据@Fraser的评论,最好在
find_library
上使用link_directories
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.