[CMake] Problem with library link order

Tom Kacvinsky tom.kacvinsky at vectorcast.com
Wed Jan 21 08:33:25 EST 2015


Unfortunately, that is not what I've found.  There are libraries we build
that have their own target_link_libraries, and if these libraries are used
on the target_link_libraries for an executable, its dependencies are also
pulled into the executables link line.  This is expected, handling of
transitive dependencies.  What is not expected is when I add libraries we
don't build, or object files, the link order gets messed up.  That and we
see duplicates of libraries.  For instance, when I pull in the the Qt
libraries, they always show up twice.  Perhaps this is because of
transitive dependencies.

In any case, there appears to be no fine grain control of link
libraries/ordering and it is driving me nuts.

I'll see if I can come up with a reproducer.  It'll be a while before I can
get one to the list.

Tom

On Tue, Jan 20, 2015 at 10:07 PM, J Decker <d3ck0r at gmail.com> wrote:

> library link order is exactly as you specify in target_link_libraries...
> each line following the last of the prior list.... so reording your library
> link list should be doable
>
> On Tue, Jan 20, 2015 at 9:57 AM, Tom Kacvinsky <
> tom.kacvinsky at vectorcast.com> wrote:
>
>> HI,
>>
>> I am using cmake 2.8,11.2 on Linux.  I am having a problem with the order
>> of libraries on the link line.  In particular, there are some static
>> archives we build that depend on a third party static archive (one we don't
>> build - it comes with the Ada compiler we are using), yet the tghird part
>> archive is on the link line (as given by the link.txt file) *before* the
>> static archives we build.  There are also problems with duplicated shared
>> libraries and a few other issues related to linking.  I have not bee able
>> to suss out what cmake is doing to construct the list of link libraries
>> used, and how it orders them.  It is very important that we have the right
>> order of libraries
>>
>> Unfortunately, our cmake files are too complicated to post here, and also
>> depend on a working Ada compiler plus the plplot projects Ada support cmake
>> "modules".  Coming up with a simple reproducer is also difficult given the
>> latter constaints.
>>
>> Can anyone point me in the right direction?  If there is a heuristic I
>> can follow - like ordering our libraries in target_link_libraries()
>> differently - I would like to hear about it.
>>
>> Thanks,
>>
>> Tom
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150121/4c370062/attachment.html>


More information about the CMake mailing list