This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Multiple definitions in STL on win32



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).  Looking
at nm output, it seems that gcc doesn't mark symbols weak when it
should...

Thanks,

Marat.



*** 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.x86-pc-win32/NodeDef.o
OBJ.x86-pc-win32/Slot.o OBJ.x86-pc-win32/cpp-output.o
OBJ.x86-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-b20/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 `operator new(unsigned int, GCPlacement)'
OBJ.x86-pc-win32/astdef.lex.o(.text$__nw__FUi11GCPlacement+0x0):/cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../../../../../include/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-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95.2/../../../../../include/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) handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
[main] ld 3464 (0) handle_exceptions: Dumping stack trace to ld.exe.core
collect2: ld returned 11 exit status







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]