Cross-Platform Programming

Posts: 64
Joined: 2005.06
Post: #1
It used to be that I had no issue programming a game that would only ever run in MacOS X, but lately I've been having second thoughts, and I like the idea more and more of cross-platform compatibility.

I've read some of the SDL docs among other things, but really, when it comes to cross-platform development, I'm a lost duck. Consider me an open mind here, so what are good suggestions for developing cross-platform?
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
It's pretty straightforward, really.

Make sure you build with every compiler you'll use early and often, because different compilers (GCC3, GCC4, MSVC, ICC) will pull you up for different things. It may well be worth using MinGW to build for Windows, because GCC3 is a lot closer to GCC4 than MSVC is Smile

Beware of case-sensitive file systems on Linux, beware of \ as a path separator on Windows, beware of different floating point math between compilers and CPU architectures, make sure you're 64-bit clean.

If you use something like SDL you may literally have one codebase for all three platforms; if not you'll have small amounts of platform-specific code to write.

If you're writing platform-specific code, make sure you're aware of the limitations and user expectations of each platform as you write each piece of functionality.

Some useful GCC Macros:
Quote this message in a reply
Posts: 370
Joined: 2006.08
Post: #3
Note that MinGW does not work on a computer running Vista with a 64-bit processor (it does not matter if the version of Vista is 64-bit or not), as the compiler itself has path issues; so far the creators of MinGW have not released a fix for this Ninja which basically forces you to move to MSVC if you're developing on that platform Sad
One thing to keep in mind: the home directories for your program are different on Windows and Macs. This means that if you are accessing files in sub-folders, you'll have to re-set your home directory to the folder where the application lies Wink
Good luck, it's really not as hard as most would have you believe ^_^

Worlds at War (Current Project) -
Quote this message in a reply
Posts: 104
Joined: 2007.01
Post: #4
Depending on your needs, here's a good set of cross-platform libraries that I use:

SDL (for audio, input, timers, and simple game graphics)
SDL_image (for loading images into SDL surfaces)
SDL_mixer (for easier use of SDL audio)
curl (for file transfers, like downloading updates or uploading high scores)
freeimage (for loading images into OpenGL textures)
boost (I only use the file system portion, for creating directories and removing files)

I would avoid using OpenAL, as the implementation is not as robust on Linux and Windows as it is on Mac.

Hope that helps.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Newbie book on cross-platform game making? and some questions... mac_girl 11 6,096 Feb 19, 2007 01:22 PM
Last Post: mac_girl
  Cross-platform RPG DarkHorizon 4 3,047 Oct 13, 2006 03:22 PM
Last Post: Leisure Suit Lurie