CMake problem: FIND_LIBRARY

My goal is to link the / usr / lib / libboinc _api.a and / usr / lib / libboinc.a libraries through CMake. Therefore, I use the examples provided in different FIND_XXXX modules, and I try:

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

But CMake does not find anything.

So I try (with 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 am I forced to clarify the extension (in FINC cmake modules, there is no extension) and how to avoid this?

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

Thank you very much.

+4
source share
1 answer

There are several errors here: firstly, the arguments after NAMES will be considered alternative libraries for searching. Therefore, if he cannot find libboinc_api, he will try libboinc before the failure. Therefore, you should rather run FIND_LIBRARY twice, one for each library.

Secondly, you need to specify the name of the library, because it will be provided in the -l linker, that is, instead of libboinc_api, you just need to specify boinc_api or the full file name, as in the second attempt.

In the case of your initial attempt, cmake will try to find liblibboinc_api.so, liblibboinc_api.a, if there is no liblibboinc.so and finally liblibboinc.a.

Try the following:

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

Perhaps in the reverse order.

+8
source

All Articles