[CMake] link issue with 2 statics lib->what's wrong in my cmake project

AKHRES Nader nader.akhres at laposte.net
Tue Mar 16 18:54:10 EDT 2010


thank you very much Bill, it works now!

Is it a big deal if I let the lib A where you advise me to remove it?

Le 16/03/2010 22:49, Bill Hoffman a écrit :
>
> AKHRES Nader wrote:
>> Hello CMake community,
>>
>> I've two libs A and B where B depends on A.
>> Then I have my final exe which depends on A and B.
>> When I generate exe project for gcc or mingw, I get undefined 
>> reference errors from B.
>> This doesn't happen with visual c++.
>>
>> Here are my cmake files organization, with relevant content between 
>> bracket:
>>
>> root
>> |--myAlib
>> |--------CMakeLists.txt [ADD_LIBRARY(A STATIC sources)]
>> |--myBlib
>> |--------CMakeLists.txt [INCLUDE_DIRECTORIES(myAlib/src) 
>> ADD_LIBRARY(B STATIC src)]
> target_link_libraries(B A)    # add this
>> |--myExe
>> |--------CMakeLists.txt [ADD_EXECUTABLE(exename src) 
>> TARGET_LINK_LIBRARIES(exename B) ]  # you can remove A from here
>> |--CMakeLists.txt [ADD_SUBDIRECTORY(myAlib) ADD_SUBDIRECTORY(myBlib) 
>> ADD_SUBDIRECTORY(myExe)]
>>
>>
>> Maybe it's something obvious I've forgotten...
>>
>
>



More information about the CMake mailing list