On Wed, Sep 28, 2011 at 5:24 PM, Ruben Van Boxem <vanboxem.ruben@gmail.com> wrote:
2011/9/28 Alen Skondro <askondro@gmail.com>


On Wed, Sep 28, 2011 at 12:44 AM, JonY <jon_y@users.sourceforge.net> wrote:
On 9/28/2011 05:44, Alen Skondro wrote:
> Hello,
>
> I have issues with linking dynamically with libstdc++.
> Static linking works.
>
> gcc is configured with ../gcc/configure --disable-multilib
> --prefix=/d/pwgcc-native --disable-nls --target=i686-w64-mingw32
> --host=i686-w64-mingw32 --enable-languages=c,c++,lto
> --enable-fully-dynamic-strings
>
> libstdc++.dll is created in /d/pwgcc-native/bin (666kB stripped) - but
> whenever i link without static this error appears:
>
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -Wl,-t -std=c++0x -o src\main.o
> ..\src\main.cc
> g++ -Wl,-t -o test-dynamic src\main.o
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/bin/ld.exe:
> mode i386pe
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/crt2.o
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/crtbegin.o
> src\main.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-_newmode.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-wildcard.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-tlssup.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-charmax.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-mingw_helpers.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-xtxtmode.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-atonexit.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-natstart.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-crt_handler.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-cinitexe.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-merr.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-dllargv.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-pseudo-reloc.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-pesect.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-CRT_fp10.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-gccmain.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-gs_support.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-tlsmcrt.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-tlsthrd.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a)lib32_libmingw32_a-pseudo-reloc-list.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/libgcc.a)_chkstk_ms.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/libgcc.a)_ctors.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingwex.a)lib32_libmingwex_a-mingw_matherr.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingwex.a)lib32_libmingwex_a-ilockcxch.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmingwex.a)lib32_libmingwex_a-ilockexch.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00252.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00122.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00060.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00059.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00105.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01069.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01061.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01118.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00160.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00143.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00317.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00982.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00892.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00069.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00583.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00421.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00056.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00758.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01098.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00321.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00108.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00998.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01016.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01153.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00958.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01121.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs00972.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfs01005.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxfh.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a)dcxft.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01085.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01073.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00553.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00580.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00510.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00771.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00339.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01152.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01149.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00774.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00603.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00434.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00437.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00627.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00871.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01117.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00433.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01097.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00223.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs01104.o
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00494.o
> src\main.o: In function `main':
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00769.o
> G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: undefined reference
> to `std::cout'
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00196.o
> G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: 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*)'
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdcs00710.o
> G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: 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>
>> &)'
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdch.o
> G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: undefined reference
> to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
> (d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a)dwdct.o
> src\main.o: In function `_tcf_0':
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/crtend.o
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../include/c++/4.6.2/iostream:75:
> undefined reference to `std::ios_base::Init::~Init()'
> src\main.o: In function `_static_initialization_and_destruction_0':
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../include/c++/4.6.2/iostream:75:
> undefined reference to `std::ios_base::Init::Init()'
> d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/bin/ld.exe:
> link errors found, deleting executable `test-dynamic.exe'
> collect2: ld returned 1 exit status
> Build error occurred, build is stopped
> Time consumed: 1259  ms.
>
>
> Thanks in advance for any hints.
>

Your trace doesn't show libstdc++ used for some reason.

With option -v (as suggested by ruben):

g++ -v -o test-dynamic src\main.o
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=d:/pwgcc-native/bin/../libexec/gcc/i686-w64-mingw32/4.6.2/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../gcc/configure --disable-multilib --prefix=/d/pwgcc-native --disable-nls --target=i686-w64-mingw32 --host=i686-w64-mingw32 host_alias=i686-w64-mingw32 target_alias=i686-w64-mingw32 --enable-languages=c,c++,lto --enable-fully-dynamic-strings
Thread model: win32
gcc version 4.6.2 20110927 (prerelease) (GCC)
COMPILER_PATH=d:/pwgcc-native/bin/../libexec/gcc/i686-w64-mingw32/4.6.2/;d:/pwgcc-native/bin/../libexec/gcc/;d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/;d:/pwgcc-native/bin/../lib/gcc/;d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/;d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../lib/;d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/;d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'test-dynamic.exe' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 d:/pwgcc-native/bin/../libexec/gcc/i686-w64-mingw32/4.6.2/collect2.exe -m i386pe -Bdynamic -o test-dynamic.exe d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/crt2.o d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/crtbegin.o -Ld:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2 -Ld:/pwgcc-native/bin/../lib/gcc -Ld:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib -Ld:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../lib -Ld:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib -Ld:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../.. src\main.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/crtend.o

src\main.o: In function `main':
G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: undefined reference to `std::cout'
G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: 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*)'
G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: 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> >&)'
G:\JAVA\WRKSPC_CXX\test-dynamic\Debug/../src/main.cc:12: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
src\main.o: In function `_tcf_0':
d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../include/c++/4.6.2/iostream:75: undefined reference to `std::ios_base::Init::~Init()'
src\main.o: In function `_static_initialization_and_destruction_0':
d:/pwgcc-native/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../include/c++/4.6.2/iostream:75: undefined reference to `std::ios_base::Init::Init()'
collect2: ld returned 1 exit status


Okay, you're not magically missing libstdc++ for some unexplained reason in the link step. Can you try my 4.6.2-2 personal build to link? I think your libstdc++ dll got mis-built:
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-2/i686-w64-mingw32-gcc-4.6.2-2_rubenvb.7z/download

Ruben


With your build it works. Now I have to find out why my libstcd++ got misbuilt.

g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o src\main.o ..\src\main.cc
g++ -v -o test-dynamic src\main.o
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=j:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.6.2/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /home/ruben/mingw-w64/toolchain/mingw32mingw32/gcc-src/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/home/ruben/mingw-w64/toolchain/mingw32mingw32/mingw32 --prefix=/home/ruben/mingw-w64/toolchain/mingw32mingw32/mingw32 --with-libexpat-prefix=/home/ruben/mingw-w64/toolchain/mingw32mingw32/prereq_install --enable-cloog-backend=isl --with-host-libstdcxx=-lstdc++ --enable-shared --enable-static --enable-threads=win32 --disable-multilib --enable-languages=all,obj-c++ --enable-libgomp --enable-libgjc --enable-fully-dynamic-string --enable-sjlj-exceptions --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror
Thread model: win32
gcc version 4.6.2 20110825 (prerelease) (GCC)
COMPILER_PATH=j:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.6.2/;j:/mingw32/bin/../libexec/gcc/;j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/;j:/mingw32/bin/../lib/gcc/;j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/;j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../lib/;j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/;j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'test-dynamic.exe' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 j:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.6.2/collect2.exe --sysroot=j:\mingw32\bin\../../mingw32 -m i386pe -Bdynamic -o test-dynamic.exe j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/crt2.o j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/crtbegin.o -Lj:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2 -Lj:/mingw32/bin/../lib/gcc -Lj:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib -Lj:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../lib -Lj:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib -Lj:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../.. src\main.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt j:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.6.2/crtend.o