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

Author Topic: making a cross platform program  (Read 10843 times)

0 Members and 1 Guest are viewing this topic.

AK_IL

  • Newbie
  • *
  • Posts: 5
    • View Profile
making a cross platform program
« on: October 26, 2014, 11:27:13 am »
Hello guys!
I've started learning about making games lately and I choose SFML and c++ for that.
Currently I'm using visual studio 2010. I built a win32 application and it works fine.
The problem is, I don't want to show the console screen together with the sfml window.
Furthermore, I searched a lot in the web but I couldn't find an answer to how compiling the project so the final executable will work in different OS's like Linux.
I hope you can help me with that or give me a reference to some information on thar .
Thank you, Alex.

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: making a cross platform program
« Reply #1 on: October 26, 2014, 11:44:11 am »
Go to your project settings -> Linker -> System and set SubSystem to Windows. Also you cannot compile for a different OS. You will need to install Unix and compile your source code on that for it to work on Unix, same with MacOS and Android and whatever else you want to run it on.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: making a cross platform program
« Reply #2 on: October 26, 2014, 12:49:01 pm »
Quote
You will need to install Unix and compile your source code on that for it to work on Unix, same with MacOS and Android and whatever else you want to run it on.
Not exactly. Although VMs with native environments are much easier to work with, you can also cross-compile. Cross-compiling is also the easiest for mobile platforms (compiling on a phone is not straight-forward ;)).
Laurent Gomila - SFML developer

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: making a cross platform program
« Reply #3 on: October 26, 2014, 12:55:19 pm »
I'll be honest and say that I'm not sure what you mean. I know that with Visual Studio you can compile for Windows on 32 and 64 bit (If your OS is 64 bit) but I wasnt aware you could cross compile from a single OS. Of course VMs are a good way to compile on another OS but nothing compares to a real OS installation.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: making a cross platform program
« Reply #4 on: October 26, 2014, 12:59:27 pm »
In my experience, unless you have to (like for some embedded targets) cross-compiling is usually a pain in the neck you don't want. A native OS install (in a VM or otherwise) with a local native tool-chain is just so much easier to work with.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: making a cross platform program
« Reply #5 on: October 26, 2014, 01:00:17 pm »
You can build a Windows executable from Linux if you install the whole cross-compilation toolchain (cross-compiler and cross-compiled libraries). The same is also available to compile Linux executables from Windows. I don't think it's as easy (or even possible) for OS X.

As I said, for Android, iOS and other mobile platforms, cross-compiling is the easiest solution. Compiling natively on a mobile platform requires some hacks (for example, to compile on an iPhone you must jailbreak it, then install gcc with Cydia and use SSH to run things directly on the phone).
Laurent Gomila - SFML developer

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: making a cross platform program
« Reply #6 on: October 26, 2014, 01:03:11 pm »
Sounds like a real hassle. This is probably another topic but is using something like NDK considered to be cross compiling? Since you are compiling from MacOS/Windows for Android.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: making a cross platform program
« Reply #7 on: October 26, 2014, 01:04:38 pm »
Yes

AK_IL

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: making a cross platform program
« Reply #8 on: October 26, 2014, 05:32:17 pm »
Laurent, how do I cross compile?
My target OS's are linux, windows and mac (Less important), not phones.
Do I have to compile it on the target OS to make an executable for it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: making a cross platform program
« Reply #9 on: October 26, 2014, 05:41:58 pm »
Quote
Laurent, how do I cross compile?
It's complicated, you'd better find a good tutorial ;)

Quote
Do I have to compile it on the target OS to make an executable for it?
As already said, this is the easiest solution.
Laurent Gomila - SFML developer

AK_IL

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: making a cross platform program
« Reply #10 on: October 26, 2014, 05:48:37 pm »
Okay, thanks.
What's the best IDE working on the different OS's that requires the fewest changes for compiling?

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: making a cross platform program
« Reply #11 on: October 26, 2014, 05:51:30 pm »
There isnt really any "best" IDE, its really personal preference. Code between IDEs is virtually the same except for any platform specific code. Visual Studio is Windows only, Code::Blocks is Windows, Linux and Mac (I think), and there is also CLion as well.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: making a cross platform program
« Reply #12 on: October 26, 2014, 07:04:11 pm »
The IDE doesn't matter. With a proper build system, like SCons, CMake, QMake or plain make, the IDE you use and the OS you build on is mostly irrelevant.

What matters is the code you write. If you write it using notepad, emacs, vi, visual studio or something else does not matter.
« Last Edit: October 26, 2014, 07:07:57 pm by Jesper Juhl »

AK_IL

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: making a cross platform program
« Reply #13 on: October 26, 2014, 08:23:05 pm »
The IDE doesn't matter. With a proper build system, like SCons, CMake, QMake or plain make, the IDE you use and the OS you build on is mostly irrelevant.

What matters is the code you write. If you write it using notepad, emacs, vi, visual studio or something else does not matter.
That's right, but how do I build a visual studio solution for example on linux OS?

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: making a cross platform program
« Reply #14 on: October 26, 2014, 08:30:36 pm »
Take the source and compile it on Linux.

 

anything