Hello, this is my first post here! I was having difficulty statically linking the binary MinGW release using Code::Blocks. I'm relatively new to both Code::Blocks and SFML, but I didn't see any explicit instructions on how to get this to work anywhere, so I figured I'd post what I had to do. I might be crazy, and there's probably an easier way of doing this.
I assume the reason this problem exists is the version of MinGW gcc Code::Blocks 10.05 ships with is different from the version SFML 1.6 was compiled with. So, in an attempt to recompile SFML with Code::Blocks 10.05, I tried following the instructions
here (under "Compiling SFML" near the bottom), but ran into problems there too.
The specific problem I ran into was that the import library naming scheme changed in Code::Blocks at some point, and the SFML Code::Blocks CBP files expect the old naming scheme (specifically, for *.dll, SFML expects *.a, and Code::Blocks now creates *.dll.a). Based on
this, this can be fixed editing the CBP files in SFML-x.y\build\codeblocks.
The specific changes I made that got things working are shown below...
diff -Naur SFML-1.6-old/build/codeblocks/sfml-audio.cbp SFML-1.6-new/build/codeblocks/sfml-audio.cbp
--- SFML-1.6-old/build/codeblocks/sfml-audio.cbp Wed Jan 27 14:53:00 2010
+++ SFML-1.6-new/build/codeblocks/sfml-audio.cbp Tue May 3 08:35:40 2011
@@ -12,7 +12,6 @@
<Option external_deps="..\..\lib\mingw\libsfml-system-d.a;" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
@@ -32,6 +31,7 @@
<Add library="..\..\extlibs\libs-mingw\libopenal32.a" />
<Add library="..\..\extlibs\libs-mingw\libsndfile.a" />
<Add directory="..\..\extlibs" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-audio-d.a" />
</Linker>
</Target>
<Target title="Release DLL_Win32">
@@ -40,7 +40,6 @@
<Option external_deps="..\..\lib\mingw\libsfml-system.a;" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-Wall" />
@@ -59,6 +58,7 @@
<Add library="..\..\extlibs\libs-mingw\libopenal32.a" />
<Add library="..\..\extlibs\libs-mingw\libsndfile.a" />
<Add directory="..\..\extlibs" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-audio.a" />
</Linker>
</Target>
<Target title="Debug static_Win32">
diff -Naur SFML-1.6-old/build/codeblocks/sfml-graphics.cbp SFML-1.6-new/build/codeblocks/sfml-graphics.cbp
--- SFML-1.6-old/build/codeblocks/sfml-graphics.cbp Wed Jan 27 14:53:00 2010
+++ SFML-1.6-new/build/codeblocks/sfml-graphics.cbp Tue May 3 08:36:00 2011
@@ -11,7 +11,6 @@
<Option object_output="..\..\Temp\sfml-graphics\Debug DLL_Win32" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
@@ -33,6 +32,7 @@
<Add library="..\..\extlibs\libs-mingw\libfreetype.a" />
<Add library="libopengl32.a" />
<Add directory="..\..\extlibs" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-graphics-d.a" />
</Linker>
</Target>
<Target title="Release DLL_Win32">
@@ -41,7 +41,6 @@
<Option external_deps="..\..\lib\mingw\libsfml-window.a;..\lib\mingw\libsfml-system.a;" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-Wall" />
@@ -63,6 +62,7 @@
<Add library="..\..\extlibs\libs-mingw\libfreetype.a" />
<Add library="libopengl32.a" />
<Add directory="..\..\extlibs" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-graphics.a" />
</Linker>
</Target>
<Target title="Debug static_Win32">
diff -Naur SFML-1.6-old/build/codeblocks/sfml-network.cbp SFML-1.6-new/build/codeblocks/sfml-network.cbp
--- SFML-1.6-old/build/codeblocks/sfml-network.cbp Wed Jan 27 14:53:00 2010
+++ SFML-1.6-new/build/codeblocks/sfml-network.cbp Tue May 3 08:36:28 2011
@@ -11,7 +11,6 @@
<Option object_output="..\..\Temp\sfml-network\Debug DLL_Win32" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
@@ -29,6 +28,7 @@
<Linker>
<Add library="ws2_32" />
<Add directory="..\..\bin\static" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-network-d.a" />
</Linker>
</Target>
<Target title="Release DLL_Win32">
@@ -36,7 +36,6 @@
<Option object_output="..\..\Temp\sfml-network\Release DLL_Win32" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-Wall" />
@@ -53,6 +52,7 @@
<Linker>
<Add library="ws2_32" />
<Add directory="..\..\bin\static" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-network.a" />
</Linker>
</Target>
<Target title="Debug static_Win32">
diff -Naur SFML-1.6-old/build/codeblocks/sfml-system.cbp SFML-1.6-new/build/codeblocks/sfml-system.cbp
--- SFML-1.6-old/build/codeblocks/sfml-system.cbp Wed Jan 27 14:53:00 2010
+++ SFML-1.6-new/build/codeblocks/sfml-system.cbp Tue May 3 08:37:07 2011
@@ -11,7 +11,6 @@
<Option object_output="..\..\Temp\sfml-system\Debug DLL_Win32" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
@@ -25,13 +24,15 @@
<ResourceCompiler>
<Add directory="..\..\src" />
</ResourceCompiler>
+ <Linker>
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-system-d.a" />
+ </Linker>
</Target>
<Target title="Release DLL_Win32">
<Option output="..\..\lib\mingw\sfml-system.dll" prefix_auto="1" extension_auto="1" />
<Option object_output="..\..\Temp\sfml-system\Release DLL_Win32" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-Wall" />
@@ -44,6 +45,9 @@
<ResourceCompiler>
<Add directory="..\..\src" />
</ResourceCompiler>
+ <Linker>
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-system.a" />
+ </Linker>
</Target>
<Target title="Debug static_Win32">
<Option output="..\..\lib\mingw\libsfml-system-s-d.a" prefix_auto="1" extension_auto="1" />
diff -Naur SFML-1.6-old/build/codeblocks/sfml-window.cbp SFML-1.6-new/build/codeblocks/sfml-window.cbp
--- SFML-1.6-old/build/codeblocks/sfml-window.cbp Wed Jan 27 14:53:00 2010
+++ SFML-1.6-new/build/codeblocks/sfml-window.cbp Tue May 3 09:42:43 2011
@@ -12,7 +12,6 @@
<Option external_deps="..\..\lib\mingw\libsfml-system-d.a;" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
@@ -31,6 +30,7 @@
<Add library="..\..\lib\mingw\libsfml-system-d.a" />
<Add library="libopengl32.a" />
<Add library="libwinmm.a" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-window-d.a" />
</Linker>
</Target>
<Target title="Release DLL_Win32">
@@ -39,7 +39,6 @@
<Option external_deps="..\..\lib\mingw\libsfml-system.a;" />
<Option type="3" />
<Option compiler="gcc" />
- <Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-Wall" />
@@ -57,6 +56,7 @@
<Add library="..\..\lib\mingw\libsfml-system.a" />
<Add library="libopengl32.a" />
<Add library="libwinmm.a" />
+ <Add option="-Wl,--out-implib=..\..\lib\mingw\libsfml-window.a" />
</Linker>
</Target>
<Target title="Debug static_Win32">
After this, it compiles fine! I hope that helps someone.
Also, in the tutorial listed earlier (
here), it says to link to the static library to add "-lsfml-system" to the linker options. I found I needed to add "-lsfml-system-s". Am I missing something?