Jump to content
  • Advertisement
Sign in to follow this  
johnmarinelli

Making a program cross-platform

This topic is 2140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

 

I have a couple simple applications built with OpenGL and SDL respectively.  I built them in VS2010, and would like them to work on the mac and unix OS.

 

I'm following the CMake tutorial on this site, but so far it seems like CMake is more for programmers sharing code across different platforms - am I wrong in this assumption?  How can I use CMake to make a release build work on an OS other than Windows?

Share this post


Link to post
Share on other sites
Advertisement

There are undoubtedly hackish ways to code for Mac OS X without having a Mac OS X machine, but in general you need a Mac OS X machine and Xcode.  You would make an Xcode project and add all the same files to it and build the same way as you do on Windows with Visual Studio.

 

I can’t answer in any specific manner for Unix, but it will basically be the same story with different tools.

 

You can’t release anything without testing it on the target platform anyway, so you will always need access to the target platform no matter what in the end, so you may as well just play it safe and simple and develop on the target machines.  It’s just more sane and allows you to find bugs progressively rather than all at once at the end of development.

 

 

L. Spiro

Edited by L. Spiro

Share this post


Link to post
Share on other sites

For linux, the first step is to use a VM (eg virtual box), install linux into it (along with g++, the dev libs you need, make/scons, etc). Set up a shared folder (to point to your source directory), and start compiling the app a lib at a time from within your VM (which will inevitably require lots of compile error fixes). Once that's complete, you'll need a round of QA testing on the game to iron out any bugs. Having done all of that, there's a good chance that porting to Mac will be slightly easier (just set up a project in XCode). CMake may help to simplify this process somewhat (since it's possible to generate the makfiles for linux, xcode projects for mac, and VCProjs for Windows), but then again, it might not. 

Share this post


Link to post
Share on other sites

CMake actually makes it relatively easy to cross-compile programs, since it does all the toolchain shenanigans for you (just tell it what toolchain to use). Sadly many libraries use something else and generally seem to be hard to cross-compile, so unless you have prebuilt binaries for them that you can just drop in the relevant folders, it's going to be troublesome.

 

Using CMake is still going to save you the headache if you just build on the target platform directly, since you'd still use the same files, so in either case stick with it. You're going in the right direction.

Share this post


Link to post
Share on other sites

I'm following the CMake tutorial on this site, but so far it seems like CMake is more for programmers sharing code across different platforms - am I wrong in this assumption?  How can I use CMake to make a release build work on an OS other than Windows?

There are two ways to achieve what you want :

 

  1. You work on windows, wants to stay on windows, and build a binary for another platform (Linux, Mac, ...) : you MUST build a cross-compiler toolchain (compiler, linker, libraries), and use this toolchain to compile others libraries (SDL), and then you can use all of this (this is called cross-compile). Hopefully, you'll find some prebuild package for popular target platform.
  2. If your target platform can host a compiler and the required libraries, copy your source code, put it on your target platform and build the platform specific binaries.

The first method is very tedious though, if there is no prebuilt binaries available on internet.

Share this post


Link to post
Share on other sites

How can I use CMake to make a release build work on an OS other than Windows?

You want to have a machine running the other OS to avoid problems.

Then, on that machine, execute CMake and it will generate the project files / build scripts needed to compile for that platform. Then you need to compile it and it's done.

 

Keep using and learning CMake. It's a very powerful tool that can save you tons of time if used correctly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!