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

Author Topic: Compiling Linux to Windows statically using Mingw  (Read 2211 times)

0 Members and 1 Guest are viewing this topic.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Compiling Linux to Windows statically using Mingw
« 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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Compiling Linux to Windows statically using Mingw
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Compiling Linux to Windows statically using Mingw
« Reply #2 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Compiling Linux to Windows statically using Mingw
« Reply #3 on: May 25, 2015, 09:00:33 pm »
Your include path ain't correct.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Compiling Linux to Windows statically using Mingw
« Reply #4 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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Compiling Linux to Windows statically using Mingw
« Reply #5 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...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Compiling Linux to Windows statically using Mingw
« Reply #6 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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Compiling Linux to Windows statically using Mingw
« Reply #7 on: May 26, 2015, 07:51:05 pm »
-L
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Compiling Linux to Windows statically using Mingw
« Reply #8 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