Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a cross-platform program

How could I write a program which runs on both Windows 7, Mac OS X (and maybe linux too)?

I heard Qt are a great framework to build cross-platform GUIs, but I think every program version need a recompile, isn't that right? And should I compile the win version under windows, the mac version under mac os x, the linux version under linux and so on?

I'm getting ideas and/or suggestions

like image 378
Marco A. Avatar asked Dec 06 '22 22:12

Marco A.


1 Answers

The underlying binary format is different on each platform, so unless you're using a virtual machine (like Java or Flash does) you will have to recompile your program on each platform.

Some compilers (like GCC) allow cross-compiling, but it is not trivial to set up. Probably the easiest system to cross-compile on is Linux (there are several open source projects that have cross compilation set up from Linux to Windows).

In case of a GUI application, it depends on the language -- if you're stuck with C++, Qt or wxWindows might be a reasonable choice providing an abstraction layer over the native windowing system.

If you can go with Java, it makes life simpler, however the windowing system is Java's and not native.

Another language to think about is FreePascal w/ Lazarus -- it has a pretty good GUI designer that compiles to the native windowing system on every platform (WinAPI on Windows, Cocoa on OSX and GTK on Linux).

like image 72
Kornel Kisielewicz Avatar answered Dec 25 '22 18:12

Kornel Kisielewicz