Hi all,
I'm using Code::Blocks 10.05++ (i. e. SVN 6752) on Ubuntu 10.04 (Lucid Lynx).
I have a pure C99 project built with the "GNU GCC Compiler" and noticed that it is linked with g++. This implies that libstdc++.so.6 is linked in which implies that also libm.so.6 is linked. Both libraries are not required by my program.
These are the libraries linked in by using g++ as linker:
xxx@yyy:~/Src/Software/BlkGlue_CB$ ldd ../BlkGlueCodeBlocks/Blkglue/bin/Release/Blkglue
linux-gate.so.1 => (0x00420000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x005a7000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00d48000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00c3b000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00de9000)
/lib/ld-linux.so.2 (0x00228000)
Trying to tell g++ with project specific command line switches to link a "C" only program seems not to be possible. So gcc must really be used.
I figured out the solution to switch the linker for dynamic libraries "Settings -> Compiler and debugger... -> Global compiler settings -> [the_compiler_you_use] -> Toolchain executables" from g++ to gcc.
These are the libraries linked in if using gcc as linker:
xxx@yyy:~/Src/Software/BlkGlue_CB$ ldd bin/Release/BlkGlue_CB
linux-gate.so.1 => (0x00efb000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00110000)
/lib/ld-linux.so.2 (0x008d8000)
After that I searched the forums for a nicer solution as this change would break the building of C++ programs as mentioned in the topic
http://forums.codeblocks.org/index.php/topic,11535.0.html .
At last I used the following workaround. In the "Settings -> Compiler and debugger... -> Global compiler settings -> " dialog I made a copy of the "GNU GCC Compiler" setup and gave it a new name "GNU G++ Compiler". For this compiler the "Toolchain executables -> Linker for dynamic libs" is switched back to g++. Therefore with this compiler setting the building of C++ programs should again be possible.
For the compiler "GNU GCC Compiler" I kept gcc as "Linker for dynamic libs" and deleted the "C++ compiler" binary so it won't compile any C++ files.
It works for me and wanted to share the results. Perhaps it is worth to include such predefined compiler settings in a future Code::Blocks release?