I am trying to set up a simple SFML test program. All it (should) do is open a window but I can't get it it run. My current system is Windows 8.1. I am using Eclipse with MinGW32 which has G++ version 4.8.1. I am building 32 bit binaries. I am using SFML 2.2.
Test Program//#define SFML_STATIC //I have this commented out because last time I tried I was dynamically linking, but I have made sure I uncommented it when I was testing the static linking
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
int main()
{
//OpenGL context settings
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.antialiasingLevel = 2; //2x anti-aliasing
//Create the window
sf::Window window(sf::VideoMode(800, 600), "Hello SFML", sf::Style::Close, settings);
bool running = true;
while(running)
{
/* Render here */
//Poll events and handle them
sf::Event windowEvent;
while (window.pollEvent(windowEvent))
{
switch (windowEvent.type)
{
//Exit if window closed
case sf::Event::Closed:
running = false;
break;
//Exit on ESC key pressed
case sf::Event::KeyPressed:
if (windowEvent.key.code == sf::Keyboard::Escape)
running = false;
break;
default:
break;
}
}
}
return 0;
}
So far I have tried both static and dynamic linking. I have also tried both debug and release modes and that had no effect on the outcome. I'd like to be able to do both of them (but if it's easier to solve one at a time I suppose I'd like to get dynamic linking working first.)
Dynamic LinkingFor dynamic linking I linked with:
sfml-system, sfml-window and included
sfml-system-2.dll and sfml-window-2.dll with the executable. The program compiles but when I try to run it I get the error: "The program has stopped working". (I have also tried building a debug version with the respective -d library versions but the result is the same). There is no other information.
Static LinkingFor the static linking I linked with:
sfml-system-s, sfml-window-s, opengl32, winmm and
gdi32.
The error I got was:
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: main.o: bad reloc address 0x80 in section `.text.startup'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operationHere is the full compilation report:
16:40:28 **** Incremental Build of configuration Release for project HelloSFML ****
Info: Internal Builder is used for build
g++ "-IC:\\Libraries\\SFML\\SFML-2.2\\include" -O3 -Wall -c -fmessage-length=0 -v -o main.o "..\\main.cpp"
Using built-in specs.
COLLECT_GCC=g++
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)
COLLECT_GCC_OPTIONS='-I' 'C:\Libraries\SFML\SFML-2.2\include' '-O3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'main.o' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/cc1plus.exe -quiet -v -I C:\Libraries\SFML\SFML-2.2\include -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.8.1/ ..\main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=pentiumpro -auxbase-strip main.o -O3 -Wall -version -fmessage-length=0 -o C:\Users\Francis\AppData\Local\Temp\ccUJ3f5e.s
GNU C++ (GCC) version 4.8.1 (mingw32)
compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/../../../../include"
ignoring duplicate directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
C:\Libraries\SFML\SFML-2.2\include
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include/c++
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include-fixed
End of search list.
GNU C++ (GCC) version 4.8.1 (mingw32)
compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 1ebc2a6f92fbd3aadc367a20a63fdf9f
COLLECT_GCC_OPTIONS='-I' 'C:\Libraries\SFML\SFML-2.2\include' '-O3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'main.o' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/as.exe -v -I C:\Libraries\SFML\SFML-2.2\include -o main.o C:\Users\Francis\AppData\Local\Temp\ccUJ3f5e.s
GNU assembler version 2.24 (mingw32) using BFD version (GNU Binutils) 2.24
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.8.1/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../
COLLECT_GCC_OPTIONS='-I' 'C:\Libraries\SFML\SFML-2.2\include' '-O3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'main.o' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
g++ "-LC:\\Libraries\\SFML\\SFML-2.2\\lib" -o HelloSFML.exe main.o -lsfml-system-s -lsfml-window-s -lopengl32 -lwinmm -lgdi32
C:\Libraries\SFML\SFML-2.2\lib/libsfml-system-s.a(String.cpp.obj):String.cpp:(.text+0xb66): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
C:\Libraries\SFML\SFML-2.2\lib/libsfml-system-s.a(String.cpp.obj):String.cpp:(.text+0xebc): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
C:\Libraries\SFML\SFML-2.2\lib/libsfml-system-s.a(String.cpp.obj):String.cpp:(.text+0x27c6): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
C:\Libraries\SFML\SFML-2.2\lib/libsfml-system-s.a(String.cpp.obj):String.cpp:(.text+0x2bd0): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Libraries\SFML\SFML-2.2\lib/libsfml-system-s.a(String.cpp.obj): bad reloc address 0x13 in section `.text.unlikely'
collect2.exe: error: ld returned 1 exit status