Help for a programming mac newbie...please?

Discussion in 'Mac Help/Tips' started by JQMonkey, Jan 6, 2003.

  1. JQMonkey macrumors newbie

    Jan 6, 2003
    I am rather new to the Mac World. When I got my iBook I was happy to see a java compiler. I will definetly be putting that to use in my upcoming semester (and wish I would have had this for my previous semester as well), but I could also use a C++ compiler. Spending $100 for software is currently not going to happen and I will already be buying two overpriced C++ books for school so I don't really want to buy another book. So basically I am looking for a free c++ compiler that will work with Jaguar. Any ideas and download locations?

    I was also wondering what kind of text editors people are using. We have gvim on the linux and unix systems we have at school but I have been unable to find info on running that on the mac. I have Jedit, but I don't like that very much so other recommendations will gladly be accepted.

    Thanks in advance.
  2. macktheknife macrumors 6502a


    Jan 24, 2002
    Mac OS X comes with its own C++ compiler. Just type gcc or gpp with the file name in Terminal to compile it. You can also download two open-source IDES jGRASP and NetBeans which provides a one-stop editor and compiler for your Java, C, and C++ programs. I recommend NetBeans.

    As for text editors, I love BBEdit, but I prefer to use Apple's Project Builder or the editors in the two aforementioned programs to write code.
  3. JQMonkey thread starter macrumors newbie

    Jan 6, 2003
    Thanks for the reply. I will check out the text editors, but....

    Trying a hello world program I typed:


    and then


    and both resulted in a command not found error. Is my computer retarded? Or is it me (quite possible) or should I be doing this in a certain folder?

    Does the netbeans thingy have a compiler built into it?
  4. macktheknife macrumors 6502a


    Jan 24, 2002
    I'll try it on my PowerBook tonight when I get home. I could be mistaken about the commands (I've been doing a lot of Java coding lately), but I have compiled both C and C++ programs before. I think the command might be "cpp" instead. Give it a shot. Make sure you have the Developer Tools installed (I'm not sure if this is necessary, but you should have them anyways if you plan on doing any development).

    And yes, NetBeans will compile your programs.
  5. zimv20 macrumors 601


    Jul 18, 2002
    they are not installed by default. w/ your ibook, monkey, you should have a developer CD. install it.
  6. cubist macrumors 68020

    Jul 4, 2002
    Muncie, Indiana
    cc -o hello hello.c

    What's gvim? Is it like vi? Vi is on mac os x.

    vi hello.c

    I don't like Project Builder. I got CodeWarrior Learning Edition and so far, I like it pretty well. There are some code samples they can give you a pointer to as well. (This is for Carbon programming, not generic C.)
  7. JQMonkey thread starter macrumors newbie

    Jan 6, 2003
    Yes, gvim is related to vi.

    first there was nothing, then the unix gods declared "let there be vi"

    Then some one came along and looked at all that the unix gods had created and said "I can do better than this, let there be vim (vi improved)"

    Then someone else came along and said "hmmm, vim is nice but I can make it look better; let there be gvim. It will open in its own window and color code different keywords for various programming languages."

    I hadn't installed the development tools so that would explain why it won't work (yet the java compiler still does it's thing). Unfortunatly all my computer stuff is at school right now so it is 500 miles away, but I am heading back on Weds. so I should be able to figure it out then.

    Thanks for the help.
  8. macktheknife macrumors 6502a


    Jan 24, 2002
    OK, here's how you do it

    I'll show you (and any future Mac C++ programmers who might read this) step-by-step instructions on compiling and running a simple "Hello, world!" C++ program using Terminal.

    1. Create a file called "hello.cpp" using any text editor. Enter the following code:
    #include <iostream.h>
    int main()
        cout << "Hello, world!\n";
    2. Open Terminal and go to the location of the file. Type (without the quotes) "c++ hello.cpp" on the command line. A file named "a.out" should have been created in the same directory if the file successfully compiled.

    3. Type (again, without the quotes) "./a.out" on the command line. "./" is a Unix command to execute a program or script.

    4. Terminal should print "Hello, world!"

    That's it! Let me know if you have any problems.
  9. benixau macrumors 65816


    Oct 9, 2002
    Sydney, Australia
    i used to programme vb on the pc for 4 yrs. i then came to the mac and have just successfully (after 10hrs intense learning) produced my very first simple cocoa programme.

    cocoa is a bugger of a language. until yo understand how it thinks. also read the apple documentation carefully and dont be afraid to try something out.

    i found that their docs are only for OS X 10.1

    they need modification to work in jag.

Share This Page