Cross Platform Programming

Any advice on how to write a program for both Linux and Windows? Using Cairo as the drawing method, but what would be the best way to produce the GUI?
Also, what would be the best toolset to use? Got VS2008.

Thanks.
A program is cross platform when all the libraries it uses are cross platform. There are plenty of cross platform gui libraries. You may want to look at GTK (and gtkmm). I believe it comes with cairo, so perhaps there is some neat special integration (never tried).
Other options are Qt and wxWidgets, though google would give you many more.
Everything I've coded beyond simple tiny test programmes for the last few years has been cross-platform (usually Linux and Win32).

I've gradually whittled my tools to a simple text editor (I use emacs), hand-crafted makefiles and the GNU Compiler Collection (or rather, the C++ compiler therein; under Win32 I had to install MinGw to use the same makefiles). It forces me to understand exactly what I'm compiling and linking, so I can be sure I'm not relying on anything platform specific.

For GUIs I use QT; I stay away from the QT IDE and again do it all manually. It leads to small, elegant code in which I can justify and explain every line, again keeping me free of anything platform specific.

I suggest you get started by creating the smallest possible code that compiles on both, producing something simple like a single QT window, and go from there. A big-bang approach of coding it all under windows and then trying to get in working on Linux instead ends up being a horrific kludge (in my experience).

"Anything can be cross platform as long as it is written for Windows."

This isn't really a joke, I wanted to point out that although Windows has some software like MingW, Cygwin and MSYS (I still have no F**** idea what MSYS is for) all of these combined have nothing on a certain Linux API wrapper called WINE.

I'm not saying that production code should be written with the intention of forcing the end user to install WINE but it's something worth messing around with.
Indeed, Wine can sometimes be a sensible target to develop for.
Every Linux system is slightly different, so it can be hard to make a native Linux application work on most systems.
By developing for Wine, you can make use of the countless hours of work that has been invested in making Wine compatible with many different systems.

I've seen several applications that actually worked better with Wine than the native Linux version (two I can remember off the top of my head are a Battle of Wesnoth beta version and SuperTux - the latter being particularly ironic :P ).
Thanks for the great advice! There is nothing like getting it from people with first hand experience. I will look into Qt for the GUI, but the WINE alternative seems very attractive, the easy way. But it seems a bit wierd to go Cairo - Wine - Linux?
Any advice on how to program to be compatible with WINE under Windows?
Wine is an implementation of the WinAPI, so programs written for Wine will usually run fine on Windows (without Wine).
However, in normal situations there is no reason to target Wine. If you're going to use cross-platform libraries anyway, you can just provide a native Linux version.
It's more a question of avoiding the incompatibilities between WINE and Windows, if I only build for Windows. As an alternative it would be necessary to know what the pifalls and limitations are.
If you code for WINE, you are actually coding for (probably a subset of) Win32 and you will be forcing people to install WINE on their machines. I would not be thrilled to get something I was told was cross-platform, only to be told it's actually Windows software and I'll have to organise an emulator.
If you code for WINE, you are actually coding for (probably a subset of) Win32 and you will be forcing people to install WINE on their machines. I would not be thrilled to get something I was told was cross-platform, only to be told it's actually Windows software and I'll have to organise an emulator.


That would NOT be cross-platform. I can run Microsoft Office 2007 in VMware but that doesn't make it cross-platform.
closed account (z05DSL3A)
mof,

You may find the following book of interest:

Cross-Platform Development in C++: Building MAC OS X, Linux, and Windows Applications
by Syd Logan

http://www.amazon.co.uk/Cross-Platform-Development-Building-Windows-Applications/dp/032124642X/ref=tmm_pap_title_0?ie=UTF8&qid=1303217904&sr=8-2
Last edited on
Thankyou Grey Wolf, the book sounds like a good idea as I'm a complete newbie at cross platform programming. To Moschops "Wine Is Not an Emulator", but I understand what you mean. It's more a matter of making the program I'm developing available for Linux users. I'm not sure how much investment in time that will involve, so WINE is an attractive alternative.

Indeed, Wine can sometimes be a sensible target to develop for.
Every Linux system is slightly different, so it can be hard to make a native Linux application work on most systems.
closed account (z05DSL3A)
To Moschops "Wine Is Not an Emulator", but I understand what you mean.

Some of us remember when it was Windows Emulator, but now it is just a compatibility layer.
Topic archived. No new replies allowed.