[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use ld options correctly for --whole-archive in automake and

From: Thomas Jahns
Subject: Re: How to use ld options correctly for --whole-archive in automake and libtool
Date: Thu, 5 Mar 2015 01:44:53 +0100

Hello Andy,

On Mar 4, 2015, at 20:05 , Andy Falanga (afalanga) wrote:
The team I work with has a project which is a C++ shared library which is exposed in two different manners. The first is a traditional C++ library and the second is it's exposed, through Boost.python, as a module. I found some great references for how to make this happen. However, I've run into a problem: wrapping, in their entirety, the libraries used in making the python module. In brief, the code is laid out thusly:

Main  (has a and files)
 |    |
 |    |- HwMgmt  (, makes libhwmgmt.a and
 |    |- Misc    (, likewise for libmisc)
 |-sata  (, produces and
 |   |
 |   |-satacpp   (sources for the C++ API for SATA lib)
 |   |
 |   |-sata      (sources wrapping satacpp in boost.python)

Since we distribute this in both a C++ and a python API, I decided to simply use the autotools as they are intended to distribute the whole thing. However, there is a problem. When I build the whole thing, from "Main", the libraries which are built for (thy python module) aren't yet built. So, they've got to be included, or linked, when we build

These aren't simply convenience libraries. So, for example, using "noinst_LTLIBRARIES =" isn't acceptable. However, the *.a files made must be entirely included into the python module. In our former, home-baked, makefile arrangement, we just built them up and included them as follows:

gcc ... -Wl,--whole-archive /path/to/first.a, /path/to/second.a - Wl,--no-whole-archive

I'm trying to reproduce this using the automake tools. I have this in the located in sata:

satacpp_la_SOURCES = ...

sata_la_LDFLAGS = -module
sata_la_LIBADD = -Wl,--whole-archive ../Shared/HwMgmt/.libs/ libhwmgmt.a ../Shared/Misc/.libs/libmisc.a .libs/libsata.a -Wl,--no- whole-archive -lz -lrt

As I'm sure no one here will be surprised, this causes automake to fail because, "linker flags such as '-Wl,--whole-archive' belong in sata_la_LDFLAGS." However, when I place this there, I find that and the final Makefile have things where I expect them, but when make runs, the libraries I've specified to be included as "whole-archive" are not listed between this option. Instead, they are listed earlier and *nothing is listed* between -Wl,--whole- archive -Wl,--no-whole-archive. I assume that libtool is doing this for me.

I'm using automake version 1.11.1, autoconf 2.63.

Any help is greatly appreciated.

This is, from my point of view not so much an automake issue but a libtool problem: libtool for some reason I don't know decided to make - Wl, be the prefix for options to be passed to libtool when it's also the prefix for gcc and various other compilers (which serve as link editor frontend) for options to pass to the linker and then decides later to pass this on to the linker program (CC/CXX/whatever). These "options" are then re-ordered with respect to non-options (like your .a files) which makes it difficult to pass them in the correct position. You might be able to work around this with judicious use of extra -Wl, prefixes like this:

sata_la_LIBADD = -Wl,-Wl,,--whole-archive,../Shared/HwMgmt/.libs/ libhwmgmt.a,../Shared/Misc/.libs/libmisc.a,.libs/libsata.a,-Wl,,--no- whole-archive -lz -lrt

But what exactly is the problem with using e.g. ../Shared/HwMgmt/ That will then require libtool should be able to set's rpath such that will be found at runtime.

Regards, Thomas

Attachment: smime.p7s
Description: S/MIME cryptographic signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]