开发者

CMake : FIND_LIBRARY problem

开发者 https://www.devze.com 2023-03-27 19:36 出处:网络
My goal is to link the libraries /usr/lib/libboinc_api.a and /usr/lib/libboinc.a through CMake. So I use the examples given in the different FIND_XXXX modules and I try :

My goal is to link the libraries /usr/lib/libboinc_api.a and /usr/lib/libboinc.a through CMake. So I use the examples given in the different FIND_XXXX modules and I try :

    FIND_LIBRARY(BOINC_LIBRARY 开发者_Go百科NAMES libboinc_api libboinc
             DOC "The Boinc libraries")
    MESSAGE(${BOINC_LIBRARY})

But CMake don't find anything.

So I try (with the extensions) :

    FIND_LIBRARY(BOINC_LIBRARY NAMES libboinc_api.a libboinc.a
             DOC "The Boinc libraries")
    MESSAGE(${BOINC_LIBRARY})

and the message gives me /usr/lib/libboinc_api.a.

So my questions are :

1) Why I am forced to precise the extension (in the cmake FIND modules, there is no extension precised) and how to avoid that ?

2) How to link the two files ? (in the current situation, the message says that only the first one is found, but maybe I misunderstand that...)

Thank you very much.


There are several mistakes here: First, the arguments after NAMES will be considered alternative libraries to search for. So if it can't find libboinc_api, it will try libboinc before failing. So you should rather run FIND_LIBRARY twice, one for each library.

Second, you need to either specify the name of the library as it would be supplied to the linker's -l option, i.e instead of libboinc_api you should just say boinc_api, or it's full filename as you did in the second attempt.

In the case of your original attempt, cmake would try to find a liblibboinc_api.so, liblibboinc_api.a, failing that liblibboinc.so, and finally liblibboinc.a.

Try this:

FIND_LIBRARY(BOINC_LIBRARY_API NAMES boinc_api
             DOC "The Boinc API library")
FIND_LIBRARY(BOINC_LIBRARY NAMES boinc
             DOC "The Boinc library")

Possibly in the reverse order.

0

精彩评论

暂无评论...
验证码 换一张
取 消