Does anyone know a good c++ compiler equivalent for MinGW on Mac OSX (10.4x)? I just started a class that requires the use of MinGW, but since it's native windows I obviously can't use it. And just to clear the air, I would rather not install Boot Camp just to use a c++ compiler.

Thanks for the help!

Recommended Answers

All 6 Replies

MinGW is a POSIX compatibility layer for Windows. Mac OSX is a POSIX system, so you can just use g++. If it doesn't already come with the system, you can download and install it without any trouble from here. The only problem is that there might be subtle differences in how MinGW and a true POSIX system behave.

Cool, I'll have to try that out tonight. I wasn't sure if I coud just use gcc that's built into XCode since the libraries might be different. Like I said I'll give it a try.

Alright, a little bit of information here. Mac OS X is indeed a POSIX operating system, built on top of FreeBSD, which is a Unix clone. It can run all tools that Unix/Linux can run, although since it's Unix clone, it's a bit modified and often Linux programs need to be modified to compile on Mac OS X</useless info>

Ravalon's link is not much good, since you'll have to do a lot of hunting to find gcc for FreeBSD that's compiled for the correct processor that's contained in your Mac. Read on.

Mac OS X by default does not come with any C/C++ compilers. Xcode, Apple's IDE can be installed from the Apple Developer disc or downloaded from their website with a free Developer Account. However, Xcode is merely an IDE - the actual Unix compilers it uses, such as g++ and gcc are installed along with Xcode.

Thus, if you have Xcode already installed, using gcc is as simple as opening up the terminal (/Applications/Utilities/Terminal) and entering something like

# gcc -c myfile.c

And it should work. Compiling Linux apps is best left to another Unix-tool wrapper, though. ;)

Hope this helps

commented: Nice :) -Raye +1

I did use XCode to create my .cpp file and compile it, didn't get any compile errors, but I also didn't get any output. If you need the code I can post it here later tonight.

Even if I do get it to run correctly, is there a way to run it as an exe, since I'll need an executable to turn in my assignment. Again, thanks for the continued help

Sorry, I assumed you knew how to use gcc. :)

Using the command I gave previously basically compiles your source into an object file, so it can be linked with any other object files and turned into an executable. No output on the console is good; it means that no errors occured. If you look in the directory where the source is, you should notice a file with the same name, but ending in .o . That's an object file.

If you want to link an object file into an executable, you can do the following:

# gcc myfile.o -o myfile

Which will create an executable named "myfile". To run, simply do the following:

# ./myfile

And your code will be executed.

Alternativey, you can skip the object file step and directly compile the file into an executable:

# gcc myfile.c -o myfile

You can also use gcc to link and compile multiple files; see the gcc manual for a very detailed guide:

Whoops, misread your post! ;) I thought you were using gcc/g++, not Xcode. For Xcode, it's as simple as pressing the Build & Run button, and a console window should pop up. For handing in the executable, simply dig around in your project's folder->Build->Development->yourexecutablehere.

Hope this helps is a link to download MinGW for Mac OS X. I don't know how well XCode integration will be, though. :-|

Note that this is just the compiler, not the runtime. Since MinGW is used to create applications for Windows, In order to get it to run on OS X (for debugging reasons) you need to get wine.

As far as a compiler/IDE for general use, get XCode. To my knowledge, it is the only IDE that uses Aqua on OS X, and it includes gcc.

Do you know if you will be building GUI Apps?

If you're not making GUI apps, you can make the apps using XCode's native GCC to debug your program, then make it with MinGW and submit it.
Just some friendly suggestions

Be a part of the DaniWeb community

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