Can’t figure out how to compile a program using precompiled SFML, or build SFML using MinGW via /r/learnprogramming

Can’t figure out how to compile a program using precompiled SFML, or build SFML using MinGW

Yes. I read the official tutorial. Yes. I followed them. Yes. I googled my problem. I don't know where else to post this since /r/sfml has it's newest posts around 20 days ago. Still I will go ahead and post it there.

Now that is out of the way, let me describe my problem. The latest SFML version provides pre-compiled SDK for MinGW. Running g++ --version on the command line yields:

g++ (GCC) 4.9.3 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

But SFML provides precompiled version for MinGW 4.9.2 (x32 version, as my mingw is x32). What the hell, let's try it anyway, I say to myself.

I create the .o file of main.cpp, the file I am trying to compile, which contains the contents of the sfml-tutorial. I do this by running g++ -c main.cpp -I include after copying the include files of SFML over into the working directory. I am happy that it runs.

Then I run g++ main.o -o sfml-app -L G:\SFML-2.4.2\lib -lsfml-graphics-s -lsfml-window-s -lsfml-system-s

Because that's where my SFML library files are downloaded, and -s because I wan't to get rid of the whole .dll not found thing.

I run into this:

main.o:main.cpp:(.text+0xf5): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale' main.o:main.cpp:(.text+0x11b): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj' main.o:main.cpp:(.text+0x157): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE' main.o:main.cpp:(.text+0x18d): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj' main.o:main.cpp:(.text+0x19e): undefined reference to `_imp___ZN2sf5Color5GreenE' main.o:main.cpp:(.text+0x1a8): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE' main.o:main.cpp:(.text+0x1c8): undefined reference to `_imp___ZN2sf6Window5closeEv' main.o:main.cpp:(.text+0x1dd): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE' main.o:main.cpp:(.text+0x20f): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh' main.o:main.cpp:(.text+0x22a): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE' main.o:main.cpp:(.text+0x23d): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE' main.o:main.cpp:(.text+0x251): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE' main.o:main.cpp:(.text+0x263): undefined reference to `_imp___ZN2sf6Window7displayEv' main.o:main.cpp:(.text+0x272): undefined reference to `_imp___ZNK2sf6Window6isOpenEv' main.o:main.cpp:(.text+0x29b): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev' main.o:main.cpp:(.text+0x2be): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev' main.o:main.cpp:(.text+0x2f8): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev' main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0xe): undefined reference to `_imp___ZTVN2sf11CircleShapeE' main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x1c): undefined reference to `_imp___ZTVN2sf11CircleShapeE' main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x2c): undefined reference to `_imp___ZN2sf5ShapeD2Ev' 

At this point I give up and think that building SFML on my own would be a better solution. So I download the src files, and run cmake-gui and configure them, and generate the makefiles. Then I run make on the directory containing the makefile, and get this:

Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. All rights reserved. 

And after leaving this for about half an hour, the command line program crashes. Can someone help me out or guide me somewhere where someone can help me out?

Submitted July 15, 2017 at 12:28PM by rusty_ballsack_42
via reddit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s