I have some program ideas that I would like to build for PC, Mac, and Linux/Unix.
The process I have in mind is to write the core libraries in C++, then program each UI based on OS.

Windows: C#
Mac: Objective-C and Cocoa
Linux/Unix: C++ and GNome/Gtk

But, I only have a PC (Windows Vista). So, is there a way to program for the Mac (and *nix) on a PC?

Thank you for your time,

- WolfShield

Recommended Answers

All 4 Replies

I believe you can, but I'm not entirely sure. Either way you will need to pay Apple a development fee to code for their products as far as I can tell, or, own a Mac.

Linux/Unix can be programmed for on a windows PC no problem.

Windows/Linux/Unix is C++ so you can program all of the core libraries in standard C++. For the UI, obviously *nix will need Gtk, but you can still code for this in Windows, you will just need to use the gcc compiler.

Windows in C#, you will need a native to managed layer and then from there you can import your libraries into C#.

I have never programmed for mac.

Why don't you program your UI in C++ and with a cross-platform GUI tool, like Qt. Qt will work everywhere. You most probably want to do your Windows coding in GCC to make sure it will compile with no problems on other OSes. Also, focus on using cross-platform libraries for anything else you might need, like threading and networking. The Boost libraries are very good for that. I also recommend you use a cross-platform build system, Qt more naturally uses qmake, but you can also use cmake.

You will need to have access to both a Mac and a Linux PC to check if your program works there, but you just need that to compile your program once it is almost complete. As long as you never use OS-specific libraries, there shouldn't be any problems. Macs are also fairly close the *nix systems.

If you have a PC, you can easily install a Linux distribution on a USB key and boot from the USB device and you will be able to test your code on Linux that way if you don't want to permanently install a Linux distro on your computer's hard-drive.

To really compile code for Mac, from a PC, you need to setup a cross-compilation. That's not an easy task in general, and I don't recommend doing it (cross-compilation is more typical when you compile for a system on which you wouldn't be able to compile anything in the first place, like micro-controllers or micro-PCs). It's easier to just borrow a Mac from a friend or something like that to compile your program once it is stably compilable under Windows and *nix.

Qt looks quite nice! But can anyone testify to it's running native looking GUIs on each of the three main OSs using the same code file?

>>But can anyone testify to it's running native looking GUIs on each of the three main OSs using the same code file?

Yes. Just google for screenshots of Qt-based applications. Pretty much any GUI tool produces "native looking" GUIs, because they are all wrapping native OS calls and constructs.

And yes, these will all be produced by the same code files (and the same GUI files, which are files produced by the GUI designer to define the design of the user interface (Qt uses the .ui extension for those files)).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.