bug-libtool
[Top][All Lists]
Advanced

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

wrong linker used for C++ on darwin


From: Chris Leishman
Subject: wrong linker used for C++ on darwin
Date: Wed, 13 Jun 2001 21:18:32 +1000

Version: 1.4 (1.920 2001/04/24 23:26:18)
--------

When linking .lo files produced from c++ sources on darwin, the link command looks something like:

libtool mode=link c++ -o libx.la -rpath /usr/local/lib x.lo

this causes libtool to run this command:

cc -dynamiclib -undefined suppress -o .libs/libx.0.0.0.dylib -compatibility_version 1 -current_version 1.0


Note that the link is done using "cc", not "c++" as specified in the call to libtool. While this should not make a difference on most platforms, it unfortunately does on darwin. This results in the library not containing dynamic linking information for linking against the c++ standard library. The outcome of this is that attempting to run clients built against this library will fail due to unresolvable symbols in the shared library. Using "c++" to link avoids this, as the standard library is correctly included.

A very naive solution is below. Knowing little about libtool internally, I have assumed that $nonopt will always contain the compiler specified on the command line.

Thank,

Chris



--- libtool.m4.orig     Wed Jun 13 21:13:15 2001
+++ libtool.m4  Wed Jun 13 21:13:33 2001
@@ -1437,7 +1437,7 @@
     # FIXME: Relying on posixy $() will cause problems for
     #        cross-compilation, but unfortunately the echo tests do not
     #        yet detect zsh echo's removal of \ escapes.
- archive_cmds='$CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linkopts -install_name $rpath/$soname $(test -n "$verstring" -a x$verstring != x0.0 && echo $verstring)' + archive_cmds='$nonopt $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linkopts -install_name $rpath/$soname $(test -n "$verstring" -a x$verstring != x0.0 && echo $verstring)'
     # We need to add '_' to the symbols in $export_symbols first
     #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols'
     hardcode_direct=yes




reply via email to

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