SFML community forums

Help => General => Topic started by: Niely on May 25, 2015, 08:20:56 pm

Title: Compiling Linux to Windows statically using Mingw
Post by: Niely on May 25, 2015, 08:20:56 pm
Hi

I've already tried different other methods, but I can't find a working one. I need to compile a SFML program from Linux to Windows (it should only work on Windows). And no, I won't be using Windows for programming this application.

I am now using Mingw on Linux, but it ain't working. My command:
i586-mingw32msvc-g++ st2.cpp -o st2.exe -lsfml-system -lsfml-graphics -lsfml-window -I /home/niely/Projects/screen_terminator/SFML/

I've also tried to put the SFML folder by the Mingw executable. Also that ain't working.

How can I do this? And how can I compile it statically so I don't need the SFML folder on other computers?

Thanks for reading,
Niely
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Nexus on May 25, 2015, 08:36:46 pm
but it ain't working.[...]
Also that ain't working.
Great error description...

Have you read the documentation of your toolchain to know if and how it supports cross-compiling?
It might be much easier to use a VM and compile things directly in a Windows environment.
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Niely on May 25, 2015, 08:46:55 pm
Compiling on Windows ain't working.

Error:
st2.cpp:6:27: error: SFML/Window.hpp: File doesn't exist.
st2.cpp:7:29: error: SFML/Graphics.hpp: File doesn'
t exist.
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Nexus on May 25, 2015, 09:00:33 pm
Your include path ain't correct.
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Niely on May 26, 2015, 04:56:37 pm
I redownloaded Windows (32-bit version) and changed my path again, and this is the new error:

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lsfml-system
collect2: ld returned 1 exit status

Command:
Quote
i586-mingw32msvc-g++ st2.cpp -o st2.exe -I /home/niely/Projects/screen_terminator/SFML-2.3/include/ -lsfml-system -lsfml-graphics -lsfml-window
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Nexus on May 26, 2015, 05:04:47 pm
Your library path ain't set :D

Maybe you should read the basic documentation of your compiler and linker before doing advanced things like cross-compiling...
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Niely on May 26, 2015, 07:37:02 pm
I've already tried the -L and -I parameter, none working. What's the working command then?
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Nexus on May 26, 2015, 07:51:05 pm
-L
Title: Re: Compiling Linux to Windows statically using Mingw
Post by: Niely on May 26, 2015, 07:58:33 pm
I've already tried that. -L without -I of course gives SFML/Window.hpp not found,

 and this command:
Quote
i586-mingw32msvc-g++ st2.cpp -o output.exe -L/home/niely/Projects/screen_terminator/SFML-2.3/lib/ -lsfml-graphics -lsfml-window -lsfml-system -I/home/niely/Projects/screen_terminator/SFML-2.3/include/

Gives the collect2: returned with status 1 exit-error.

By the way, using the normal G++ (no mingw) this works perfectly:
g++ -o st st2.cpp -lsfml-system -lsfml-network -lsfml-graphics -lsfml-window