Cross-platform writing

How can I write a program that runs on both Windows 7 and Mac OS X (and possibly Linux)?

I heard that Qt is a great infrastructure for building cross-platform graphical interfaces, but I think every version of the program needs to be recompiled, right? And do I need to compile the win version under windows, the mac version under Mac OS X, the Linux version under Linux, etc.?

I get ideas and / or suggestions

+4
source share
5 answers

The basic binary format is different on each platform, so if you are not using a virtual machine (such as Java or Flash), you will have to recompile your program on each platform.

Some compilers (for example, GCC) allow cross-compilation, but it is not trivial to configure it. Probably the easiest cross-compilation system is Linux (there are several open source projects that have cross-compilation configured from Linux to Windows).

In the case of a GUI application, it depends on the language - if you are stuck with C ++, Qt or wxWindows can be a smart choice providing a level of abstraction over your own windows system.

If you can go with Java, it will make life easier, however the window system is Java and is not native.

Another language worth considering is FreePascal w / Lazarus - it has a pretty good graphic designer that compiles to its own windows system on each platform (WinAPI on Windows, Cocoa on OSX and GTK on Linux).

+5
source

Not sure C ++ is required, but Adobe Air is a great cross-platform development environment for desktop computers, as well as its development for mobile development. If you need an example of a large application that uses Adobe Air to deploy on multiple desktop OSs, just check tweetdeck http://www.tweetdeck.com/

I would also recommend looking in Flex and Flash Builder if you go this route.

+3
source

There are two separate problems that I would like to highlight when writing cross-platform programs - how to make your code portable and how to organize its creation on different platforms.

As for the construction part of things, I would look at a cross-platform build system like CMake ( http://www.cmake.org ). You essentially write a script, and CMake will create the appropriate project file / makefile for a specific platform. Then you create your program on each platform, as usual. For example, on Windows, you can use CMake to create a Visual C ++ project for you, and then use Visual C ++ to create your own executable. On Linux, you can use CMake to create a makefile and then create an executable using g ++.

Another aspect is how to make your code portable - the key is to write C ++ standard compatible code and use libraries that themselves are portable to the platforms you are interested in. to) write platform-specific code for each of the different platforms - if you do, you must hide it behind a portable interface and use the rest of the code.

+3
source

Yes, you need to compile each version when using C ++.

The only thing that prevents you from compiling a program, for example, for Windows on a Mac, is to get a tool for this. It is possible, but the problem is finding a toolbox.

You can also use a virtual machine to run various operating systems and compile code for all platforms on one computer.

+2
source

Java runs on Windows, OS X and Linux

+1
source

All Articles