Reputation: 591
Possibly I will make some implicit assumptions. If any of them are wrong, please correct me.
Win32, TDM GCC 4.6.1, Codeblocks 10.05, Codeblocks is able compile C++ using the gnu toolchain.
As far as I know it is possible to link the stdlibc++ dynamically and statically too. Currently CodeBlocks links libstdc++ statically. Although I could not find any settings relating to the dynamic/static linking in the codeblocks "build settings" panel, I could verify, using process monitor the it links the c++ standard library statically.
CodeBlocks executes g++ with these parameters:
mingw32-g++.exe -o bin\Release\fltk-hello.exe
obj\Release\fltk-hello.o -s C:\MinGW32\lib\libfltk.a
C:\MinGW32\lib\libgdi32.a C:\MinGW32\lib\libole32.a
C:\MinGW32\lib\libuuid.a C:\MinGW32\lib\libcomdlg32.a
C:\MinGW32\lib\libcomctl32.a
Then, there is a call from g++:
"c:/mingw32/bin/../libexec/gcc/mingw32/4.6.1/collect2.exe"
"-Bdynamic" "-o" "bin\Release\fltk-hello.exe" "-s"
"c:/mingw32/bin/../lib/gcc/mingw32/4.6.1/../../../crt2.o"
"c:/mingw32/bin/../lib/gcc/mingw32/4.6.1/crtbegin.o"
"-Lc:/mingw32/bin/../lib/gcc/mingw32/4.6.1"
"-Lc:/mingw32/bin/../lib/gcc"
"-Lc:/mingw32/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/lib"
"-Lc:/mingw32/bin/../lib/gcc/mingw32/4.6.1/../../.."
"obj\Release\fltk-hello.o" "C:\MinGW32\lib\libfltk.a"
"C:\MinGW32\lib\libgdi32.a" "C:\MinGW32\lib\libole32.a"
"C:\MinGW32\lib\libuuid.a" "C:\MinGW32\lib\libcomdlg32.a"
"C:\MinGW32\lib\libcomctl32.a" "-Bstatic" "-lstdc++" "-Bdynamic"
"-lmingw32" "-lgcc" "-lmoldname" "-lmingwex" "-lmsvcrt" "-ladvapi32"
"-lshell32" "-luser32" "-lkernel32" "-lmingw32" "-lgcc" "-lmoldname"
"-lmingwex" "-lmsvcrt"
"c:/mingw32/bin/../lib/gcc/mingw32/4.6.1/crtend.o"
Now, this part
"-Bstatic" "-lstdc++"
Makes it clear, that stdc++ is linked statically. I could also verify in process explorer that the loaded dlls do not contain libstdc++-6.dll.
I looked around the codeblocks build settings pages and found nothing. Codeblock provides the possibility to add parameters to g++. Unfortunately I could not find explicit gcc parametes to turn on the dynamic linking of libstdc++, the docs at http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html say
If libstdc++ is available as a shared library, and the -static option is not used, then this links against the shared version of libstdc++.
So, how can I make it link dynamically to stdc++?
Upvotes: 2
Views: 4632
Reputation: 591
Finally, I have found a solution. One has to add
-shared-libstdc++
to the linker options. Now it links stdc++ libs dynamically.
Upvotes: 1