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

Re: How do I get libtool to use g++?

Neil Roeth <neil@debian.org> writes:

> I recently had a bug (193950) filed against one of my packages because the
> shared libraries had "undefined non-weak symbols" - libstdc++ was not being
> linked in.  I resolved it with what I consider a gruesome hack.  I discovered
> that forcing libtool to use g++ while linking would automatically link in
> libstdc++.  The hack came about because I could not figure out how to get
> libtool to use g++ instead of gcc.  So, I did
> sed -e 's/CC="gcc"/CC="g++"/g' libtool > lt.tmp && mv -f lt.tmp libtool
> to force it.  What's the right way to get libstdc++ linked in to shared
> libraries of C++ code?  The package uses autoconf, automake, libtool, etc.
I think I have found a solution for resoving the "libtool doesn't use
g++" problem and have sucessfully used it in a pkg of mine:

1) run libtoolize --force, using libtool 1.5 (not yet in Debian)
2) Copy libtool.m4 from libtool 1.5 to your package's m4 dir (this is to
   make aclocal use the new libtool.m4, since it doesn't look in
   /usr/local/, where libtool 1.5 is presumably installed, until a .deb
   comes in).
3) run aclocal
4) Make automake use libtool's --tag feature: put the following line into
   the .am file that builds the shared lib:

   CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@

   This will override AM's default link line.
5) rebuild
Hopefully future versions of automake will support this without ugly hacks.

Regards, Andy
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

Make free software, not war!

Reply to: