[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
prog_LDADD at the end of the linking command line
From: |
Benoit SIGOURE |
Subject: |
prog_LDADD at the end of the linking command line |
Date: |
Fri, 19 Oct 2007 18:48:25 +0200 |
Hello list,
[CC: Akim: that's why trunk doesn't compile on Windows/MinGW]
In a project where we use both Automake and Libtool, I have a program
named `uconsole' which depends on Boost and a libtool library
`libkernel.a' built in the same directory (which also depends on Boost).
Here is an excerpt from our Makefile.am:
--------------------------------------------------------------------
# Add boost libraries.
AM_CXXFLAGS += $(BOOST_CPPFLAGS)
AM_LDFLAGS += $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
lib_LTLIBRARIES = libkernel.la
libkernel_la_SOURCES = manythings
noinst_PROGRAMS = uconsole
uconsole_SOURCES = console.cc
uconsole_LDADD = libkernel.la
--------------------------------------------------------------------
Now the problem is that when linking `uconsole', I get undefined
references because of the way `uconsole_LDADD' has been appended to
the linking command line:
--------------------------------------------------------------------
/bin/sh ../libtool --tag=CXX --mode=link mingw32-g++ -mthreads -I/
usr/local/include -g -O2 -pipe -L/usr/local/lib -lboost_thread-mt -o
uconsole.exe console.o libkernel.la -lws2_32 -lgdi32
mingw32-g++ -Wno-deprecated -Wall -W -Woverloaded-virtual -Wformat -
Wno-uninitialized -Werror -Wcast-align -Wcast-qual -Wwrite-strings -
mthreads -IC:/cygwin/usr/local/include -g -O2 -pipe -o uconsole.exe
console.o -LC:/cygwin/usr/local/lib -lboost_thread-mt ./.libs/
libkernel.a -lws2_32 -lgdi32
--------------------------------------------------------------------
See, libkernel.a comes at the end whereas Boost is listed
beforehand. And, as you know, the way the linker works entails that
undefined references to Boost found in libkernel.la won't be resolved.
The generated Makefile looks like this:
--------------------------------------------------------------------
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
[...]
uconsole$(EXEEXT): $(uconsole_OBJECTS) $(uconsole_DEPENDENCIES)
@rm -f uconsole$(EXEEXT)
$(CXXLINK) $(uconsole_OBJECTS) $(uconsole_LDADD) $(LIBS)
--------------------------------------------------------------------
Have we done something wrong? How can we get this to work? :)
Oddly enough, the project builds fine on Linux (gcc3/gcc4), OSX
(Intel/PPC) and Windows VC++, but not on Windows with MinGW!
And, of course, if I manually run the link command with `libkernel.a'
before `-lboost_thread-mt', it links fine.
Thanks.
--
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory
PGP.sig
Description: This is a digitally signed message part
- prog_LDADD at the end of the linking command line,
Benoit SIGOURE <=