[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug creating shared library with convenience libraries for Sun C++ compi
From: |
Albert Chin |
Subject: |
Bug creating shared library with convenience libraries for Sun C++ compiler |
Date: |
Mon, 16 Feb 2004 01:37:44 -0600 |
User-agent: |
Mutt/1.4i |
I'm attempting to build libxml++ on Solaris 8. The libxml++ shared
library contains a number of convenience libraries:
$ /bin/ksh ../libtool --mode=link CC -xO2 -xtarget=generic -o
libxml++-1.0.la -rpath /opt/TWWfsw/libxml++10/lib -version-info 1:1:0
attribute.lo dtd.lo document.lo noncopyable.lo keepblanks.lo
-R/opt/TWWfsw/libxml25/lib -R/opt/TWWfsw/zlib11/lib
-R/opt/TWWfsw/libiconv18/lib -L/opt/TWWfsw/libxml25/lib
-L/opt/TWWfsw/zlib11/lib -L/opt/TWWfsw/libiconv18/lib -lxml2 -lpthread
-lz -liconv -lm -lsocket -lnsl parsers/libparsers.la
exceptions/libexceptions.la nodes/libnodes.la io/libio.la
The result is a libxml++.so file that does not have all of the members
from the convenience libraries linked in:
...
CC -v -G -nolib -hlibxml++-1.0.so.1 -o .libs/libxml++-1.0.so.1.0.1
.libs/attribute.o .libs/dtd.o .libs/document.o .libs/noncopyable.o
.libs/keepblanks.o -Qoption ld -z -Qoption ld allextract
parsers/.libs/libparsers.a exceptions/.libs/libexceptions.a
nodes/.libs/libnodes.a io/.libs/libio.a -Qoption ld -z -Qoption ld
defaultextract -R/opt/TWWfsw/libxml25/lib -R/opt/TWWfsw/zlib11/lib
-R/opt/TWWfsw/libiconv18/lib -R/opt/TWWfsw/libxml25/lib
-R/opt/TWWfsw/zlib11/lib -R/opt/TWWfsw/libiconv18/lib
-R/opt/TWWfsw/zlib11/lib:/opt/TWWfsw/libiconv18/lib
-L/opt/TWWfsw/libxml25/lib -L/opt/TWWfsw/zlib11/lib
-L/opt/TWWfsw/libiconv18/lib /opt/TWWfsw/libxml25/lib/libxml2.so
-lpthread /opt/TWWfsw/zlib11/lib/libz.so
/opt/TWWfsw/libiconv18/lib/libiconv.so -lm -lsocket -lnsl
...
/usr/ccs/bin/ld -dy -G -hlibxml++-1.0.so.1 -z allextract -z
defaultextract -R/opt/TWWfsw/libxml25/lib -R/opt/TWWfsw/zlib11/lib
-R/opt/TWWfsw/libiconv18/lib -R/opt/TWWfsw/libxml25/lib
-R/opt/TWWfsw/zlib11/lib -R/opt/TWWfsw/libiconv18/lib
-R/opt/TWWfsw/zlib11/lib:/opt/TWWfsw/libiconv18/lib
-R/opt/SUNWspro/lib/rw7:/opt/SUNWspro/lib:/opt/SUNWspro/lib:/usr/ccs/lib:/usr/lib
-o .libs/libxml++-1.0.so.1.0.1 /opt/SUNWspro/WS6U2/lib/crti.o
/opt/SUNWspro/WS6U2/lib/CCrti.o .libs/attribute.o .libs/dtd.o
.libs/document.o .libs/noncopyable.o .libs/keepblanks.o
parsers/.libs/libparsers.a exceptions/.libs/libexceptions.a
nodes/.libs/libnodes.a io/.libs/libio.a -L/opt/TWWfsw/libxml25/lib
-L/opt/TWWfsw/zlib11/lib -L/opt/TWWfsw/libiconv18/lib
/opt/TWWfsw/libxml25/lib/libxml2.so -lpthread
/opt/TWWfsw/zlib11/lib/libz.so /opt/TWWfsw/libiconv18/lib/libiconv.so
-lm -lsocket -lnsl -Y
P,/opt/SUNWspro/lib/rw7:/opt/SUNWspro/lib:/opt/SUNWspro/WS6U2/lib/rw7:/opt/SUNWspro/WS6U2/lib:/usr/ccs/lib:/usr/lib
/opt/SUNWspro/WS6U2/lib/CCrtn.o /opt/SUNWspro/WS6U2/lib/crtn.o
>&/tmp/ld.11005.0.err
Note "-z allextract -z defaultextract" on the command line. We want
the .a files *between* the allextract/defaultextract.
C libraries with convenience libraries don't have this problem as we
call ld directly.
The patch below fixes this and reworks the tagdemo test.
--
albert chin (address@hidden)
-- snip snip
2004-02-15 Albert Chin-A-Young <address@hidden>
* libtool.m4: When linking convenience libraries on Solaris
with the Sun C++ compiler, pass convenience libraries through
to the linker with -Qoption between allextract/defaultextract.
The Sun C++ compiler bundles -Qoption arguments so
convenience libraries are linked with defaultextract
otherwise.
* tagdemo/Makefile.am, tagdemo/main.cpp, tagdemo/conv.h,
tagdemo/conv.cpp: Augment tagdemo test to link a convenience
library with a libtool library.
--- libtool.m4 11 Feb 2004 12:18:48 -0000 1.314.2.28
+++ libtool.m4 16 Feb 2004 06:55:56 -0000
@@ -3378,9 +3343,13 @@ case $host_os in
*)
# The C++ compiler is used as linker so we must use $wl
# flag to pass the commands to the underlying system
- # linker.
+ # linker. We must also pass each convience library through
+ # to the system linker between allextract/defaultextract.
+ # The C++ compiler will combine linker options so we
+ # cannot just pass the convience library names through
+ # without $wl.
# Supported since Solaris 2.6 (maybe 2.5.1?)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z
${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z
${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" &&
new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"`
${wl}-z ${wl}defaultextract'
;;
esac
_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
--- tagdemo/Makefile.am 1 Jun 2002 14:09:50 -0000 1.4
+++ tagdemo/Makefile.am 16 Feb 2004 07:31:45 -0000
@@ -6,19 +6,23 @@ AUTOMAKE_OPTIONS = no-dependencies forei
EXTRA_DIST = acinclude.m4
-noinst_LTLIBRARIES = libfoo.la
-lib_LTLIBRARIES = libbaz.la
+noinst_LTLIBRARIES = libconv.la
+lib_LTLIBRARIES = libfoo.la libbaz.la
libfoo_la_SOURCES = foo.cpp
libfoo_la_LDFLAGS = -no-undefined
-libfoo_la_LIBADD = $(LIBM)
+libfoo_la_LIBADD = libconv.la $(LIBM)
# Test some of the ILD support when using tagged configurations.
libbaz_la_SOURCES = baz.cpp
libbaz_la_LDFLAGS = -no-undefined
libbaz_la_LIBADD = libfoo.la
-noinst_HEADERS = foo.h baz.h
+# Test convenience libraries.
+libconv_la_SOURCES = conv.cpp
+libconv_la_LDFLAGS = -no-undefined
+
+noinst_HEADERS = foo.h baz.h conv.h
bin_PROGRAMS = tagdemo
--- tagdemo/main.cpp 1 Apr 2002 21:59:09 -0000 1.4
+++ tagdemo/main.cpp 16 Feb 2004 06:55:57 -0000
@@ -22,6 +22,7 @@
#include "foo.h"
#include "baz.h"
+#include "conv.h"
#include <iostream.h>
@@ -58,6 +59,11 @@ main (int, char *[])
// foobar_derived::foo(), which in turn calls ::foo().
if (bb->baz() == FOO_RET)
cout << "barbaz::baz is ok!" << endl;
+
+ // --------------
+
+ if (convenience())
+ cout << "convenience is ok!" << endl;
return 0;
}
--- /dev/null Sun Mar 24 15:28:28 2002
+++ tagdemo/conv.h Mon Feb 16 01:30:52 2004
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+// conv.h -- part of the interface to the libfoo* libraries
+// Copyright (C) 1998-1999 Free Software Foundation, Inc.
+// Originally by Thomas Tanner <address@hidden>
+// This file is part of GNU Libtool.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+
+// Only include this header file once.
+#ifndef _CONV_H_
+#define _CONV_H_ 1
+
+// Our C test functions.
+extern "C"
+{
+ int convenience(void);
+}
+
+#endif /* !_CONV_H_ */
--- /dev/null Sun Mar 24 15:28:28 2002
+++ tagdemo/conv.cpp Mon Feb 16 01:32:53 2004
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+// conv.cpp -- trivial convenience test library
+// Copyright (C) 1998-2000 Free Software Foundation, Inc.
+// Originally by Thomas Tanner <address@hidden>
+// This file is part of GNU Libtool.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+
+#include "conv.h"
+
+// Our C functions.
+int
+convenience(void)
+{
+ return 1;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug creating shared library with convenience libraries for Sun C++ compiler,
Albert Chin <=