[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to use ld options correctly for --whole-archive in automake and libt
From: |
Andy Falanga (afalanga) |
Subject: |
How to use ld options correctly for --whole-archive in automake and libtool |
Date: |
Wed, 4 Mar 2015 19:05:47 +0000 |
Hi,
First of all, forgive my earlier e-mail of "Subscribe" to this. I was a bit
confused at the time reading the website. Now for the question.
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 Makefile.am and configure.ac files)
|
|-Shared
| |
| |- HwMgmt (Makefile.am, makes libhwmgmt.a and libhwmgmt.so)
| |- Misc (Makefile.am, likewise for libmisc)
|
|-sata (Makefile.am, produces libsatacpp.so and sata.so)
| |
| |-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 sata.so (thy python module) aren't yet built. So, they've
got to be included, or linked, when we build sata.so.
These aren't simply convenience libraries. So, for example, using
"noinst_LTLIBRARIES = libhwmgmt.la" 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
Makefile.am located in sata:
lib_LTLIBRARIES = satacpp.la
satacpp_la_SOURCES = ...
pyexec_LTLIBRAIRES = sata.la
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 Makefile.in
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.
Andy
Re: How to use ld options correctly for --whole-archive in automake and libtool, Gavin Smith, 2015/03/05