This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/13805] New: undefined symbol when linking libstdc++.a
- From: "walther at caltech dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jan 2004 02:12:11 -0000
- Subject: [Bug libstdc++/13805] New: undefined symbol when linking libstdc++.a
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This has been reported before but not resolved (#12595).
When trying to build a shared library with libstdc++ linked in statically (for
self-containment), the symbol std::time_put_w@@GLIBCPP_3.2 is undefined:
//test.cpp
#include<iostream>
void doit()
{
std::cout << "Hello World!\n";
}
//end test.cpp
g++ -shared -static -v -Wl,-v -o test.so test.cpp
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libstdc++.a
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/cc1plus -v -D__GNUC__=3
-D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=2 -D__GXX_ABI_VERSION=102 -D__ELF__
-Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__
-D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1
-D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__
-D__tune_i386__ test.cpp -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet
-dumpbase test.cpp -version -o /tmp/cc2HiSkY.s
GNU CPP version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) (i386-redhat-linux)
compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.2.2
/usr/include/c++/3.2.2/i386-redhat-linux
/usr/include/c++/3.2.2/backward
/usr/local/include
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include
/usr/include
End of search list.
as -V -Qy -o /tmp/ccvdM737.o /tmp/cc2HiSkY.s
GNU assembler version 2.13.90.0.18 (i386-redhat-linux) using BFD version
2.13.90.0.18 20030206
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/collect2 -m elf_i386 -shared -o
test.so /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crti.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtbeginT.o
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. -v /tmp/ccvdM737.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libstdc++.a -lstdc++ -lm -lgcc -lgcc_eh
-lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtendS.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crtn.o
collect2 version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) (i386 Linux/ELF)
/usr/bin/ld -m elf_i386 -shared -o test.so
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crti.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtbeginT.o
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. -v /tmp/ccvdM737.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libstdc++.a -lstdc++ -lm -lgcc -lgcc_eh
-lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtendS.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crtn.o
/usr/bin/ld: test.so: undefined versioned symbol name std::time_put_w@@GLIBCPP_3.2
/usr/bin/ld: failed to set dynamic section sizes: Bad value
GNU ld version 2.13.90.0.18 20030206
collect2: ld returned 1 exit status
I have reproduced the problem in gcc versions 3.2.2 and 3.3.2. It was not
present in 3.1. I have tried a RedHat 8.0 and a Mandrake 9.2 system. I have
tried bootstrapping the compilers from scratch, also with the previously
suggested --with-pic option - the problem persists.
In libstdc++.a the symbol time_put_w is versioned, which it did not use to be in
gcc 3.1:
nm /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libstdc++.a | grep time_put_w
00000000 B _ZN9__gnu_cxx10time_put_wE
00000000 B _ZSt10time_put_w@@GLIBCPP_3.2
U _ZN9__gnu_cxx10time_put_wE
nm: stubs.o: no symbols
Please help!
Dirk
--
Summary: undefined symbol when linking libstdc++.a
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: walther at caltech dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13805