View Full Version : compiling a pc app in a mac using c++???

Oct 13, 2004, 10:37 PM
im new to programing and learning c++ (Im using XCode to compile) I was wondering, If I want to program a pc application how can I compile it? using xcode? or do I need to use a pc to compile it?

and heres other question (maybe stupid but Im still learning...):
how much difference has the code between a mac and pc application, I mean If I already have the code of one application I made, how much of the code will I have to change to make it work on a pc, or if its a pc version how much code will I need to change to make it work on a mac.
for example I want to program a software that runs both on mac and pc, will the same code work or I'll have to make twice the work. I think the only differences are in the user interface, am I right?
I have a lot of people requesting me software for pc, but i want to code the applications in my mac. is this posible or should I get a pc (and beleive me, I dont like the idea...)

Oct 13, 2004, 10:56 PM
Thats the main difference and the source of all your problems with code of pc and mac. The user interface are different. Except if you decide to use wxWidgets. I'm using it for a project I'm working on and tried the same code on both Linux and Mac. No problems what so ever. The only one I can think of is letting the code know where the libraries are. SUppose same thing will happen with windows.

But from a point of view code wise, everything that is crunching numbers should be ok on any platform. Differences can be how good the precision is on the platform. That what I can think of. Regarding your first question on compiling a pc app using xcode. You need to let know xcode where the libraries are that the app needs.

As long as you use C or C++ can't think of any change between windows and mac. (If I'm wrong please someone help with this) you might find yourself learning objective-c at some point. Have read that is what is used to program on the Mac.

Hope this make sense and should I be wrong feel free to correct me.

Oct 14, 2004, 02:39 PM
I want to program a software that runs both on mac and pc, will the same code work or I'll have to make twice the work.

You may want to look into Java + Swing.

Oct 14, 2004, 03:08 PM
Yes, Java + Swing seems to be your answer. Straight C++ with no GUI is mostly the same, except for the little/big endian thing, but once you want to do something a little more complicated, and this does not just include GUI, you usually want to use some framework, like the Windows32 API or the Apple frameworks.

There are some cross platform frameworks for C++ (Trolltechs Qt is one), but the easiest solution for a developer is Java, because the Java frameworks are really quite powerful.

The main drawback with Java is that it sometimes requires people to install java in addition to you application. The speed of Java is almost as good as C++ now, if you know what you're doing, except for start up, which tends to be slower. Also, sometimes things aren't as platform independent as you would wish, so you have to test on all platforms, but that would be the case for all solutions for cross platform development.

And Java + Cocoa won't work on Windows either.