gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Compile for different platforms

#171266 - redoc - Tue Nov 10, 2009 9:42 pm

Hi all, its been well over a year since visiting and I really miss GBA programming days.

I was wondering about starting a new project and how I would go about compiling it on different platforms.

So lets say I want to make the same game on the DS, iPhone, and Wii. What is the best way to use the same code but compile for the different hardware?

Should I have a seperate project folder for each system? or just a different "makefile"

I understand the C/C++ will compile across the systems, what I dont understand is the unique parts to each system. Such as loading the graphics (DS uses memory banks, I doubt the iphone does?) Plotting pixels as 16bit only, vs other system requirements. Making sense?

Any thoughts would be greatly appreciated.

TIA

#171268 - gauauu - Tue Nov 10, 2009 11:07 pm

That really depends on how you set things up, and how different the different platforms are.

Your best bet might be to have a source directory that is the common engine of the game, and then a source directory for each platform. With separate makefiles, and a few selective uses of the preprocesser (Which you might even be able to avoid if you design it well), you should be ok.

That way you don't have to maintain separate almost-identical codebases for the different platforms (which is a mistake I made when I ported Anguna from GBA to DS). When I fixed a bug in one platform, I had to go back and fix it in the other as well.

#171283 - redoc - Wed Nov 11, 2009 7:47 pm

hi gauauu, thanks for getting back to me!

Thats along the lines how I thought, not too up with makefiles yet so I'll work on that a little and see what experiments I can come up with.

I really want to avoid having to make tweaks or bug-fixes on every version... knowing me I would make a right mess of it trying to manually keep it all 'in sync'

#171285 - Drovor - Wed Nov 11, 2009 9:51 pm

If you want a relatively simple example of a Makefile, I have a program that can be built on the DS or PC. One Makefile for each system, and a third that picks which one to use (i.e. 'make pc' and 'make ds').

I don't know if thats the best way to do it, but it works for me.

http://github.com/drovor/LoggerDS