Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: help compiling my game for Windows  (Read 1846 times)

0 Members and 2 Guests are viewing this topic.

Knarf0

  • Newbie
  • *
  • Posts: 7
    • View Profile
help compiling my game for Windows
« on: September 11, 2014, 06:38:05 pm »
Hi,

My game compiles and runs just fine on Linux (Debian), but when I try to create a Windows binary using mingw it fails.

Here is how I compile :
Quote
i586-mingw32msvc-g++ -W -Wall -DSFML_DYNAMIC -ltgui -lsfml-system -lsfml-window -lsfml-graphics -lsfml-network -lsfml-audio -std=c++11 main.cpp -o main.exe

and this is the output :
(click to show/hide)

lib files are in the right path, otherwise it would have said "Cannot find -libsfml-..."

Thanks for your help.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: help compiling my game for Windows
« Reply #1 on: September 11, 2014, 07:18:49 pm »
Your link order is wrong.
system should be last, graphics before window, and window network audio before system.

Unless you're using 1.6 you don't need SFML_DYNAMIC for dynamic linking.
« Last Edit: September 11, 2014, 07:28:11 pm by G. »

Knarf0

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: help compiling my game for Windows
« Reply #2 on: September 11, 2014, 07:52:39 pm »
Thanks for your reply you made me figure out the solution.

It works with
Quote
i586-mingw32msvc-g++ main.cpp -o main.exe -W -Wall -DSFML_DYNAMIC -ltgui -lsfml-system -lsfml-window -lsfml-graphics -lsfml-audio -lsfml-network -std=c++11

So the problem was that "main.cpp -o main.exe" should be the first argument and not the last (it's not comfy because I was using an alias). It's strange because when I use just g++ I can put these arguments wherever I want.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: help compiling my game for Windows
« Reply #3 on: September 11, 2014, 08:03:56 pm »
It's not "strange". It is simply a function of how incremental linking works. Look it up in your compilers documentation.
Note: the rules are different for static and dynamic linking and vary by platform/compiler/compiler-linker options (in some cases). But it is not magic; you just have to know the rules for the OS+compiler+linker combo that you are using.
As a general rule you should be fine if you always put objects that depend on other objects before the objects they depend on (if you have cyclic dependencies you are in for some trouble, so don't do that).