Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to cross-platform ?

Started by Sereath Dec 2, 2011 at 2:25 PM 16 replies 3.5k views
Original Post
Sereath
Sereath
Hi,

I am what I'd like to call a "wanna be developer" creating games and applications during my free time (using opengl, qt, irrlicht, ogre and good old c++).

About 2 months ago I decided to roll up my sleeves and start doing cross platform software/games. I go trough the trouble of having a triple boot computer (W7, Ubuntu, Mac 10.6)

...but then I'm lost. I am really swimming since a month trying to figure out how should I go about creating a project that is cross platform.
I enjoyed using codeblock on windows but it is unstable on mac. I tried xcode but I feel deeply uncomfortable using it (I know you all like it, I don't, I will do my best to like it if it is necessary though).
As for Linux I go a little more success compiling a basic ogre app on linux but am still a little bit lost in this see of dependencies)
So here are a few questions :

- Is there a application or something that facilitate the process of creating a cross platform project.
- Should I build a cross-platform makefile with my bare hands ?
- What is the process of creating a cross-platform (if you have time to write your 2 cent I would really appreciate it)


Thanks ahead for your time.
SimonForsman
SimonForsman

Hi,

I am what I'd like to call a "wanna be developer" creating games and applications during my free time (using opengl, qt, irrlicht, ogre and good old c++).

About 2 months ago I decided to roll up my sleeves and start doing cross platform software/games. I go trough the trouble of having a triple boot computer (W7, Ubuntu, Mac 10.6)

...but then I'm lost. I am really swimming since a month trying to figure out how should I go about creating a project that is cross platform.
I enjoyed using codeblock on windows but it is unstable on mac. I tried xcode but I feel deeply uncomfortable using it (I know you all like it, I don't, I will do my best to like it if it is necessary though).
As for Linux I go a little more success compiling a basic ogre app on linux but am still a little bit lost in this see of dependencies)
So here are a few questions :

- Is there a application or something that facilitate the process of creating a cross platform project.
- Should I build a cross-platform makefile with my bare hands ?
- What is the process of creating a cross-platform (if you have time to write your 2 cent I would really appreciate it)


Thanks ahead for your time.


The easy way:
Use C# with opentk or Java with LWJGL. (This lets you do all developing on one platform and all you really need to do is test the application on the others)

The slightly harder way:
Use a good cross platform IDE (Mac can be tricky though)

Or in worst case, use something like qmake to generate makefiles for all your platforms.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Bregma
Bregma
If you're using Qt anyways, why not use QtCreator as an IDE/buildsystem? It works the same on all platforms. It works well.

Other than that, you're pretty much limited to either using the GNU autotools for everything but Microsoft Windows and using Microsoft Visual Studio on Microsoft Windows (unless you go the cygwin/mingw route, which opens a can of pain you might wish had been left back on the conveyor at the supermarket) or cmake to generate "projects" for some subset of IDEs on various platforms, then run around adjusting each one one at a time in an endless loop.

Oh, and the 1990s ended over a decade ago, no need to triple boot any more. All the cool kids (read: productive people) use multiple VMs for development instead, reserving native boots for a subset of final testing.

PS. don't go the C# route unless by "cross-platform" you mean "Microsft Windows Vista, Microsoft Windows 7, and the Microsoft X-Box".
Stephen M. Webb
Professional Free Software Developer
Serapth
Serapth
First off, many of us hate XCode 4, even among the rabidly fanboyish Apple dev culture there are those that really hate Xcode 4.x.

Second, frankly when learning, take out as many variables as possible. Writing portable code is a good thing, often a very good thing, but it is generally a misguided feature for a new developer.


If you really want to write portable code, write it in an environment that abstracts the underlying hardware. Flash, Unity, Corona, et al. Otherwise, learn a language that is capable of targeting multiple platforms, such as Java or C#, learn the language *then* learn about portability. Scripting languages such as Python or Lua sit in the middle between abstracted languages and general purpose languages and are generally easier to write portable code in.
kunos
kunos

PS. don't go the C# route unless by "cross-platform" you mean "Microsft Windows Vista, Microsoft Windows 7, and the Microsoft X-Box".


and linux, and mac, and ios and android and, maybe soon, ps vita...rolleyes.gif




Serapth
Serapth

[quote name='Bregma' timestamp='1322840694' post='4889799']
PS. don't go the C# route unless by "cross-platform" you mean "Microsft Windows Vista, Microsoft Windows 7, and the Microsoft X-Box".


and linux, and mac, and ios and android and, maybe soon, ps vita...rolleyes.gif





[/quote]

Don't forget FreeBSD! Oh, or Solaris ( http://www.mono-project.com/Mono:Solaris ).
swiftcoder
swiftcoder
CMake. It is a 'meta-makefile' in a certain sense. Also the answer to all your woes.

Cmake generates native project files on every platform (XCode for Mac, Visual Studio for Windows, Makefiles for linux, etc.), is braindead simple to use, and handles locating dependencies automatically.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
GSnake
GSnake
Sorry for this newbish question but giving your code for a specific platform to a "cross-platformer" does or does not affect performance of the final product?
Serapth
Serapth

Sorry for this newbish question but giving your code for a specific platform to a "cross-platformer" does or does not affect performance of the final product?


Not on a level that you need to worry about initially. It is possible that some code needs to be implemented in a platform specific manner to perform adequately, but there are ways to handle platform specific code in a cross platform specific manner. Ultimately it's a bridge you cross if and when you get to it, which could be a substantial way down the road.


If you are using a cross platform library, like SFML, SDL or Ogre, they generally take care of the platform specific performance areas.
Sereath
Sereath
Thanks you all for your time & valuable replies.

Il try do do a little summary of what are my options from your apreciated advices :


1) Platform abstraction

Using a language that let you code once and run everywhere
(Such as Java, C#, or even just in time compiled codes written in Python, Lua an such)


2) Compiler abstraction (maybe not the best title I guess)

Using a cross platform IDE that once setup properly let you build a project for the current OS with the press of a button.
(Qt Creator, Codeblock)

I did a quick research on the web and also found these ones that might be relevant and seems still alive :
(Eclipse, Code Lite, NetBeans, XPower++)


3) Writing makefiles
I've heard there are still some helpers programs for that (beside the IDE who do all the job for you) but frankly I just don't know how it works or where to start or how it works over all, basically I'm in the dark (I will mention here that I code in my free times and never really had classes about it).
I guess I've heard a few programs in this topic such as : cmake and qmake.


Thanks for telling me about C# cross platform capabilities, il dig into that hoping it isn't at the cost of performance.
Thanks a lot Bregma for telling me about Qt Creator. I've started using Qt and enjoyed it (especially once I finally got it to compile my slots and signals) but never used it's tools thus never knew it has it's own IDE. Hopefully using Qt Creator will make it a lot easier to compile for Qt anyway.



Oh, and the 1990s ended over a decade ago, no need to triple boot any more. All the cool kids (read: productive people) use multiple VMs for development instead, reserving native boots for a subset of final testing.
I hear you there, I went trough all this trouble a few weeks ago just to find out yesterday (coincidence I guess) about a tutorial on lifehacker about having 3 virtual machines that let you just switch OS without even having to re-boot. All it takes is a tons of rams. I just hope 4Gb is enough...




First off, many of us hate XCode 4, even among the rabidly fanboyish Apple dev culture there are those that really hate Xcode 4.x.

Second, frankly when learning, take out as many variables as possible. Writing portable code is a good thing, often a very good thing, but it is generally a misguided feature for a new developer.
Haha, good to know I'm not alone having problems to enjoy using xcode.

Going cross platform shall not slow my learning process since it is the very thing I want to learn ATM. Thanks for telling me about it's misguidance though it is a relief to me as I was constantly afraid of missing something obvious thus this topic I started.

I am well aware that creating a cross-platform application isn't a piece of cake, actually I see this as a nearly impossible task yet I am committed and I deeply want to create a cross platform application. And I want it to behave properly on all platforms (yes I'm just that crazy). If in the end I realize I just don't have what it takes, fine il accept it. For now I am just getting warmed up : bring it on cross-platform !





If you are using a cross platform library, like SFML, SDL or Ogre, they generally take care of the platform specific performance areas.
I've heard about softwares that given a complex problem (thermal analisys, lot of calculs) and yet given the exact same parametters, the same software would give different results depending on the platform you run it on. Is this true/possible and if so does using libraries specific variables avoid this problem (such as using ogre's integers rather than normal c++ integer)
Serapth
Serapth

1) Platform abstraction

Using a language that let you code once and run everywhere
(Such as Java, C#, or even just in time compiled codes written in Python, Lua an such)


C# and Java are not write once languages. Java was sold as one, but that is a myth. Granted, they are more portable than C or C++ in most regards, but you still need to do work on a platform by platform basis. The only language of any real complexity that managed to be write once run anywhere is basically Flash/Actionscript, amazingly enough. Not that I want you to take that as an endorsement.



I did a quick research on the web and also found these ones that might be relevant and seems still alive :
(Eclipse, Code Lite, NetBeans, XPower++)
[/quote]
Eclipse and NetBeans are very much still alive, and if you are doing Java, both good choices. NetBeans 7.1 beta is a buggy mess and Eclipse should go die in a fire, especially the C++ aspects. There are people alive that like Eclipse, but then, there are people alive that like Justice Beiber, so that isn't really saying much.


3) Writing makefiles
I've heard there are still some helpers programs for that (beside the IDE who do all the job for you) but frankly I just don't know how it works or where to start or how it works over all, basically I'm in the dark (I will mention here that I code in my free times and never really had classes about it).
I guess I've heard a few programs in this topic such as : cmake and qmake.
[/quote]

At this stage in your development, pretend this aspect simply does not exist. It is a level of complexity you simply do not need added. Note, I am not saying it is complex, there is a difference. The key thing for you to do at this stage is focus on what is important, and at this stage, this is not important.


Thanks for telling me about C# cross platform capabilities, il dig into that hoping it isn't at the cost of performance.
[/quote]

For a very long time, the biggest performance bottleneck is going to be you. Until that isn't the case, probably years down the road, do not worry about this issue. It is a point of distraction that will for the most part only cause you and your development harm.



I am well aware that creating a cross-platform application isn't a piece of cake, actually I see this as a nearly impossible task yet
[/quote]

It isn't. Frankly it isn't really even all that difficult. It is simply a distraction you needn't concern yourself with right now. Noticing a trend?

I've heard about softwares that given a complex problem (thermal analisys, lot of calculs) and yet given the exact same parametters, the same software would give different results depending on the platform you run it on. Is this true/possible and if so does using libraries specific variables avoid this problem (such as using ogre's integers rather than normal c++ integer)
[/quote]

Then that is badly written software. There are some platform specific issues like endian-ness that you will *eventually* need to be aware of, but frankly most code should behave consistently across platforms, even without taking special cases into account. In fact the further you stay away from optimization and language concepts you don't yet understand the MORE LIKELY it is your code will be portable!
return0
return0
Use As3/Flash11, and Air3 for mobile when it comes out for write once run anywhere 3D?
swiftcoder
swiftcoder

Use As3/Flash11, and Air3 for mobile when it comes out for write once run anywhere 3D?

I feel like Adobe's decision to abandon mobile flash, probably spells bad news for Adobe Air on the mobile too, in the long run...
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
return0
return0
Why? Canning mobile web player was a political, not technical move.
All8Up
All8Up

CMake. It is a 'meta-makefile' in a certain sense. Also the answer to all your woes.

Cmake generates native project files on every platform (XCode for Mac, Visual Studio for Windows, Makefiles for linux, etc.), is braindead simple to use, and handles locating dependencies automatically.


I'd second CMake but you have to be honest and say that it's script language sucks huge hairy donkey nuts. Writing a CMake lists file can be as complicated as any makefile out there because of the complicated way it tries to maintain macro replacement in the middle of a script language. For simple things, sure, works like a charm. Get much more advanced and the macro language becomes a nightmare.

I use CMake, it is the best x-plat generator solution, but misrepresenting it as easy, sorry I won't go that far.
swiftcoder
swiftcoder

Why? Canning mobile web player was a political, not technical move.

Well, sure, the Flash IDE will be re-targetted to produce native code on mobile/desktop, and HTML 5 for the web. But it will be slowly replaced by Edge.

However, one of Flash's major benefits was write-once-run-anywhere, with no need to deploy. Now you have to deploy separately for each platform, in their own app stores, and so forth. That isn't any different than the situation on iOS right now, but extending that policy to Android, Windows Phone, and every embedded TV/game console in creation, is likely to hurt platform penetration as a whole... And since Adobe is already investing is separate content creation tools for HTML 5 (which will eventually incorporate all the current benefits of Flash), I'd call it a pretty safe bet that Flash is on the way out.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
SimonForsman
SimonForsman
I've heard about softwares that given a complex problem (thermal analisys, lot of calculs) and yet given the exact same parametters, the same software would give different results depending on the platform you run it on. Is this true/possible and if so does using libraries specific variables avoid this problem (such as using ogre's integers rather than normal c++ integer)
[/quote]

Yes this is true/possible but should only be a problem if you run on different architectures, some languages such as Java solve this for you at the expense of some performance on low accuracy platforms, There are also fixed point math or software floating point math libraries for C++ you can use instead of the native math functions (This would also cost quite a bit of performance) (Windows, Linux and Mac OSX normally all run on x86 these days so it is not a big problem, if on the other hand you need to also run on architectures such as IA64 or SPARC then you might have to deal with this problem as they have significantly higher accuracy for things like trig functions etc than the x86 has (Even if you are using the same number of bits for your datatypes).
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.