I have followed the newest SFML 2.2 tutorial to build/compile SFML and link it to my project(s). So I built SFML 2.2 in debug and release mode for MinGW 32 bit (gcc 4.7.1) and it worked just fine as my 64 bit release builds (MinGW 64 gcc 4.9.0, TDM 64 gcc 4.8.1 and TDM 64 gcc 4.9.2). The .a files seemed to work just fine until I tried the simple example for drawing a green circle. I have no bugs in 64 bit with either of my compilers but when I'm in 32 bit with MinGW gcc 4.7.1, I get "undefined references at every line".
Here's my build log:
g++.exe -Wall -fexceptions -static-libgcc -opt-static -DSFML_STATIC -DGLEW_STATIC -DGLM_FORCE_RADIANS -DDGLEW_STATIC -g -DDEBUG -DBITS_32 -std=c++11 -I"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\include" -I"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\extlibs\headers" -I"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\extlibs\headers\libfreetype\windows" -I"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\extlibs\headers\libsndfile\windows" -c "D:\CodeBlocks Workspace\Templates\SFML 2_2 Template\main.cpp" -o obj\Debug\main.o
g++.exe -L"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\extlibs\bin\x86" -L"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\cmake build\Debug\lib\MinGW 32" -L"D:\CodeBlocks Workspace\Do not touch\Librairies\SFML 2.2\extlibs\libs-mingw\x86" -o "bin\Debug\SFML 2_2 Template.exe" obj\Debug\main.o -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-network-s-d -lsfml-audio-s-d -lsfml-system-s-d -lglew -lws2_32 -lopenal32 -lsndfile -lgdi32 -lwinmm -lfreetype -ljpeg -lglu32 -lopengl32
obj\Debug\main.o: In function `main':
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:7: undefined reference to `sf::Color::Green'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:15: undefined reference to `sf::Window::close()'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:19: undefined reference to `sf::RenderStates::Default'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:20: undefined reference to `sf::Window::display()'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:9: undefined reference to `sf::Window::isOpen() const'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
D:/CodeBlocks Workspace/Templates/SFML 2_2 Template/main.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\main.o: In function `ZN2sf11CircleShapeD1Ev':
D:/CodeBlocks Workspace/Do not touch/Librairies/SFML 2.2/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
D:/CodeBlocks Workspace/Do not touch/Librairies/SFML 2.2/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
D:/CodeBlocks Workspace/Do not touch/Librairies/SFML 2.2/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `sf::Shape::~Shape()'
How my linking process work is that I link every optional libraries at the end of each build target, except for glew because in 64 bit its name is glew32 (wtf Microsoft...). Then, in each build target, I add the respective link to each sfml libraries. For example, if it's a debug target, then I add -d but they all have -s. Also, depending on the architecture, I give the search directories for the linker:
32 bit
- extlibs\bin\x86
- cmake build\Debug\lib\MinGW 32 (SFML 2.2 source I built myself)
- extlibs\libs-mingw\x86
64 bit
- extlibs\bin\x64
- cmake build\Release\lib\MinGW 64 (SFML 2.2 source I built myself, MinGW 64 is an example)
- extlibs\libs-mingw\x64
TL;DR
64 bit works fine, 32 bit doesn't work. The only differences are glew and searching directories. Everything except the external libraries is compiled by myself.
[/list]