简体   繁体   中英

Linking ready made external static library

I have a ready made external static library (.a) that I want to link to my executable. How exactly can I do it with cmake?

You should use the TARGET_LINK_LIBRARIES command. But before that you might want to make sure CMake looks into correct directories by using FIND_LIBRARY or LINK_DIRECTORIES . All are documented in detail here: ( CMake help: TARGET_LINK_LIBRARIES ) ( CMake help: LINK_DIRECTORIES ) ( CMake help: FIND_LIBRARY )

According to the comment by @Fraser, it is better to use find_library over link_directories .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM