Multiple definition error in STL?

Andrew Begel abegel@cs.berkeley.edu
Fri Mar 10 18:05:00 GMT 2000


I am getting a multiple definition problem compiling a program that
uses STL 3 with Cygwin GCC 2.95.2, binutils 2.9.4 under Win2K.
Compiling the exact same program on Linux and Solaris with GCC 2.95.2
yields no errors.  In some cases, adding -O1 to the compilation fixes
the error, and in some cases it does not.  Is this a known problem?
Is there a workaround?  (The exact errors are at the end of this
message).

Thanks,

andy begel

*** This is the case that can be fixed by adding -O1:

/cygnus/cygwin-b20/H-i586-cygwin32/bin/gcc -o OBJ.x86-pc-win32/test   OBJ.x86-pc
-win32/error.o OBJ.x86-pc-win32/memory.o OBJ.x86-pc-win32/trace.o OBJ.x86-pc-win
32/debug.o OBJ.x86-pc-win32/diag.o OBJ.x86-pc-win32/timer.o OBJ.x86-pc-win32/Poo
ledString.o OBJ.x86-pc-win32/DList.o OBJ.x86-pc-win32/EDList.o OBJ.x86-pc-win32/
SearchPath.o OBJ.x86-pc-win32/stl.o OBJ.x86-pc-win32/test.o         -Wl,-export-
dynamic -L/cygnus/cygwin-b20/H-i586-cygwin32/lib -lstdc++ -L/harmonia/gc/gc -lgc

/cygnus/cygwin-b20/H-i586-cygwin32/lib/libstdc++.a(iostream.o)(.text+0x2ae0):ios
tream.cc: multiple definition of `ostream::operator<<(ostream &(*)(ostream &))'
OBJ.x86-pc-win32/test.o(.text$__ls__7ostreamPFR7ostream_R7ostream+0x0):/cygnus/c
ygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../../../../..
/include/g++-3/stl_hashtable.h: first defined here
collect2: ld returned 1 exit status

*** Nothing helps here:

/cygnus/cygwin-b20/H-i586-cygwin32/bin/gcc -o OBJ.x86-pc-win32/astdef   OBJ.x86-
pc-win32/Attribute.o OBJ.x86-pc-win32/DefFile.o OBJ.x86-pc-win32/Method.o OBJ.x8
6-pc-win32/NodeDef.o OBJ.x86-pc-win32/Slot.o OBJ.x86-pc-win32/cpp-output.o OBJ.x
86-pc-win32/main.o OBJ.x86-pc-win32/astdef.lex.o OBJ.x86-pc-win32/astdef.tab.o
 ../common/OBJ.x86-pc-win32/libcommon.o   -Wl,-export-dynamic -L/cygnus/cygwin-b
20/H-i586-cygwin32/lib -lstdc++ -L/harmonia/gc/gc -lgc
../common/OBJ.x86-pc-win32/libcommon.o: In function `_stl_prime_list':
/cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../..
/../../../include/g++-3/stl_hashtable.h(.text+0x5f20): multiple definition of `o
perator new(unsigned int, GCPlacement)'
OBJ.x86-pc-win32/astdef.lex.o(.text$__nw__FUi11GCPlacement+0x0):/cygnus/cygwin-b
20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../../../../../includ
e/g++-3/std/bastring.h: first defined here
../common/OBJ.x86-pc-win32/libcommon.o: In function `_stl_prime_list':
/cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../..
/../../../include/g++-3/stl_hashtable.h(.text+0x6b08): multiple definition of `o
perator new [](unsigned int, GCPlacement)'
OBJ.x86-pc-win32/astdef.lex.o(.text$__vn__FUi11GCPlacement+0x0):/cygnus/cygwin-b
20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../../../../../includ
e/g++-3/std/bastring.h: first defined here

[... many more similar errors skipped ...]

To complete the picture, this error extravaganza happily ends with:

[main] c:\cygnus\cygwin-b20\H-i586-cygwin32\i586-cygwin32\bin\ld.exe 3464 (0) ha
ndle_exceptions: Exception: STATUS_ACCESS_VIOLATION
[main] ld 3464 (0) handle_exceptions: Dumping stack trace to ld.exe.core
collect2: ld returned 11 exit status








--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list