Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C++ Compiler for Mac Leopard that is NOT Xcode?

  1. Feb 3, 2009 #1
    I am a novice (very novice) C++ user. I use Dev C++ on my PC. I really love it because it is very clean and simple. I just click File->new->new source code and I am there. There is an editing window and a building workspace is opened automatically.

    Is there something comparable to Dev C++ for Macs? I tried Xcode and so far I hate it.

    Just looking for some (free) alternatives.

    Any thoughts?

  2. jcsd
  3. Feb 3, 2009 #2
  4. Feb 3, 2009 #3
    Rootx, I don't think that would be very helpful to salad's situation.

    Saladsamurai: If you have xcode installed then you also have gcc installed. (This is basically the only compiler out there for os x, so anything else you download will just be a shell for gcc. There probably do exist such shells-- macvim?-- but I wouldn't know what they are.) If you want to compile something with gcc, just open a terminal window and say:

    g++ yourfilename.cpp -o yourprogramname

    However if you are doing any kind of "real" (i.e. GUI) application development you want to use XCode because it does stuff like framework linking for you.

    If you don't like XCode you don't have to interact with it very much. Just find an XCode project file suitable to your situation, modify the source files, and pretend XCode itself doesn't exist other than the 'compile and run' button.
  5. Feb 3, 2009 #4


    User Avatar
    Science Advisor
    Homework Helper

    Basically anything that runs on Linux should be available for OS-X, the other common IDE is Eclipse http://www.eclipse.org/
    As coin says the actual compiler is generally the excellent gcc
  6. Feb 3, 2009 #5
    Thanks for the suggestions guys. I guess I really do not know what I am talking about. And it is even harder for me to explain what it is I do not like since I do not know the lingo at all.

    mgb: You helped me track down Dev C++. Have you used it? I basically just want to be able to open a new source file and write some some crappy code and then execute it.

    I have been going into Xcode and selectingFile-->New project-->(on command line utility tab) C++ tool.

    Then I get a little lost. I have to save the project as something, which creates a Folder.

    then this window comes up


    Then I select "main.cpp" and this comes up:


    and for some reason that stupid "Hello World" program always opens under main.cpp

    I think that is there as some kind of a template. It is created everytime I open a new project.

    When I run it...no terminal comes up. I have to toggle back to this screen, and select the file with the black icon named "Untitled"


    Though, now the word "Untitled" is black since there is some code that has been built.
    After clicking it, this piece of crap of a terminal comes up and displays the output:


    Maybe I am just being a baby since I am so used to Dev C++ and now I have to get used to this.

    I hate that terminal window. I need to figure out if there is a way to change the default colors and if it is necessary for all that garbage to come up with it (i.e., everything except "Hello World").
  7. Feb 3, 2009 #6
    Essentially, yes. XCode is a superb IDE, second only to Visual Studio in my opinion. For what it's worth, I didn't like XCode much when I first encountered it either. Perseverance pays off though.

    Unfortunately I'm typing this on a Windows machine and, given that I've had a beer or two, can't vouch for the accuracy of what I'm about to say. However, pressing Command-B (or maybe it's Command-Shift-B) should build and run the project for you. Since the default contents of main.cpp are just a simple Hello World app, this should pop up a console window in which the application runs.

    You've just compiled and run the source code to Hello World. What, precisely, do you expect? Doom 3?

    Command-, gives you access to preferences in OS X. Change your terminal settings via that!
  8. Feb 4, 2009 #7


    User Avatar
    Science Advisor
    Homework Helper

    Thats the good part, on windows it would just pop up a window behind the IDE somewhere and immediately close it after the program had run before you could see anything

    If you just want to learn c without using the ide you can just run gcc on the commandline.
    Last edited: Feb 4, 2009
  9. Feb 4, 2009 #8


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Quick question, if I may butt in: Is the Xcode version of gcc much different from the regular GNU gcc? I am a Mac noob wanting to compile C on a Mac OS X. I've only ever written code when I absolutely have had to, and those times, I was using gcc on a linux machine.
  10. Feb 4, 2009 #9


    User Avatar
    Science Advisor
    Homework Helper

    Depends exactly which version of GCC installs with xcode. But no there is no difference in the same version of GCC running on different platforms.
    The libraries will be differnet of course to handle the different OS.
  11. Feb 4, 2009 #10


    User Avatar

    Staff: Mentor

    If that's all you want to do, you don't need no steenkin' fancy-pants IDE. :devil:

    Just fire up the Terminal application (in the Applications:Utilities folder) and do the following (what you type is in boldface):

    Code (Text):
    [yourmac:~] yourname% [B]pico hello.cpp[/B]
    This fires up a simple text editor. Enter your source code, then hit ^X to exit.

    Code (Text):
    [yourmac:~] yourname% [B]g++ hello.cpp -o hello[/B]
    This compiles your code, links it to the standard library, and places the executable in the file 'hello'.

    Code (Text):
    [yourmac:~] yourname% [B]./hello[/B]
    Hello, world!
    When you get to the point of breaking up your program into lots of separate source files and having to compile and link them together, or you have to use lots of nonstandard libraries (e.g. if you start writing Mac OS GUI applications), that's when an IDE like Xcode starts to save you time. But for basic C++ coursework programs, it's overkill.
    Last edited: Feb 4, 2009
  12. Feb 8, 2009 #11
    I feel your pain i was in you same situation 2years ago when i got a mac. What i would recommend is codeblocks. Its just as good as VS and in my opioion it is better than Dev-C++.

  13. Feb 8, 2009 #12
    Hi Tacoma,

    That's interesting, does Code::Blocks have a native mac interface or does it run in the X Server?

    Also does Code::Blocks have any special features for supporting wxWindows development, if one is interested in doing that?
  14. Feb 8, 2009 #13
    Code::Blocks is crap even on Windows; why anyone would recommend the appalling OS X version is beyond me.

    (And Code::Blocks is "just as good as [Visual Studio]"? Even allowing for a truly enormous number of vacua, I doubt there's a universe in which that's the case. :wink:)
  15. Feb 9, 2009 #14
    Your not the first person who has told me this. I Code::Blocks appeals to me more for some reason. Is good how ever im not a .net developer, im an open source deveplover so cross-platform support is more ideal.

    However you have to realize that he said he was beginner and you have to agree that using code::blocks is easier than using Xcode and faster than elipse.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: C++ Compiler for Mac Leopard that is NOT Xcode?
  1. C++ compilers (Replies: 24)