Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 415221 - cross-i686-pc-mingw32/gcc-4.5.3-r2 g++ can't link programs with STL
Summary: cross-i686-pc-mingw32/gcc-4.5.3-r2 g++ can't link programs with STL
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: crossdev-bugs
  Show dependency tree
 
Reported: 2012-05-09 11:05 UTC by M8R-u38wij
Modified: 2017-08-15 19:22 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
i686-pc-mingw32-logs.tar.bz2 (i686-pc-mingw32-logs.tar.bz2,165.46 KB, application/x-bzip)
2012-05-09 11:06 UTC, M8R-u38wij
Details
emerge-info (info,16.03 KB, text/plain)
2012-05-09 11:08 UTC, M8R-u38wij
Details
helloworld.cpp (helloworld.cpp,91 bytes, text/plain)
2012-05-09 11:21 UTC, M8R-u38wij
Details
link.log (link.log,21.08 KB, text/plain)
2012-05-11 22:44 UTC, M8R-u38wij
Details

Note You need to log in before you can comment on or make changes to this bug.
Description M8R-u38wij 2012-05-09 11:05:24 UTC
Arter installing i686-pc-mingw32 with crossdev I try to compile helloworld.cpp and linkage fails with next error next error:
$ i686-pc-mingw32-g++ -c helloworld.cpp
$ i686-pc-mingw32-g++ helloworld.o
/tmp/ccLGjfxr.o:helloworld.cpp:(.text+0x19): undefined reference to `std::cout'
/tmp/ccLGjfxr.o:helloworld.cpp:(.text+0x1e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccLGjfxr.o:helloworld.cpp:(.text+0x26): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccLGjfxr.o:helloworld.cpp:(.text+0x2e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccLGjfxr.o:helloworld.cpp:(.text+0x47): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccLGjfxr.o:helloworld.cpp:(.text+0x6a): undefined reference to `std::ios_base::Init::Init()'
collect2: ld returned 1 exit status


Reproducible: Always

Steps to Reproduce:
1.# crossdev --stable --target i686-pc-mingw32
2.$ i686-pc-mingw32-g++ -c helloworld.cpp
3.$ i686-pc-mingw32-g++ helloworld.o
Actual Results:  
Linkage fails, can't find STL objects

Expected Results:  
Linkage success

Installation logs of mingw32 toolchain are attached
Comment 1 M8R-u38wij 2012-05-09 11:06:52 UTC
Created attachment 311227 [details]
i686-pc-mingw32-logs.tar.bz2
Comment 2 M8R-u38wij 2012-05-09 11:08:15 UTC
Created attachment 311229 [details]
emerge-info
Comment 3 M8R-u38wij 2012-05-09 11:21:12 UTC
Created attachment 311231 [details]
helloworld.cpp
Comment 4 SpanKY gentoo-dev 2012-05-11 08:53:05 UTC
works fine for me

# qlist -Iv cross-i686-pc-mingw32
cross-i686-pc-mingw32/binutils-2.22-r1
cross-i686-pc-mingw32/gcc-4.5.3-r2
cross-i686-pc-mingw32/mingw-runtime-3.18
cross-i686-pc-mingw32/w32api-3.17.2
# i686-pc-mingw32-g++ -c helloworld.cpp
# i686-pc-mingw32-g++ helloworld.o
# file a.exe
a.exe: PE32 executable (console) Intel 80386, for MS Windows

try running the command:
# i686-pc-mingw32-g++ helloworld.o -v -Wl,--verbose |& grep stdc
 /usr/libexec/gcc/i686-pc-mingw32/4.5.3/collect2 --sysroot=/usr/i686-pc-mingw32 -Bdynamic /usr/i686-pc-mingw32/mingw/lib/crt2.o /usr/lib/gcc/i686-pc-mingw32/4.5.3/crtbegin.o -L/usr/lib/gcc/i686-pc-mingw32/4.5.3 -L/usr/i686-pc-mingw32/mingw/lib helloworld.o --verbose -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i686-pc-mingw32/4.5.3/crtend.o
attempt to open /usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a succeeded
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d002780.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d002781.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d002858.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d000982.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d002516.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d002514.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d000000.o
(/usr/lib/gcc/i686-pc-mingw32/4.5.3/libstdc++.dll.a)d003506.o
Comment 5 M8R-u38wij 2012-05-11 22:44:16 UTC
Created attachment 311457 [details]
link.log

full output of
# i686-pc-mingw32-g++ helloworld.o -v -Wl,--verbose
Comment 6 M8R-u38wij 2012-05-15 15:44:25 UTC
(In reply to comment #4)

Works correctly on my x86 PC and produces error on amd64 laptop. On which architecture you run it?
Comment 7 SpanKY gentoo-dev 2012-05-16 05:17:21 UTC
my amd64 desktop
Comment 8 M8R-u38wij 2012-05-27 11:10:49 UTC
Works fine after upgrade to gcc-4.6.3
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2012-06-29 20:29:50 UTC
I had such problems when I had two migw32-g++ installed:
4.5 (active) and 4.7.

For some reason 4.5 had empty libstdc++.

4.6.3 seems to produce binaries, but they are broken.
Even simple <iostream>y "hello world" produced by 4.6.3
dies before main() (somewhere in sjlj.dll loader).

Binaried built winh 4.7.1 look and run fine.