Running C++ from Terminal

Discussion in 'Mac Programming' started by gamestriker, Aug 3, 2005.

  1. gamestriker macrumors regular

    Joined:
    Dec 18, 2004
    #1
    I started learning C++ a year ago, on a Unix machine, and I learned how to compile and run on a normal Unix console. I tried to pick up were I left off a year ago, but when I tried doing 'a.out' in Terminal to run the compiled program, it threw an error at me saying 'command not found'. Is there another way to run it off the Terminal?

    I appreiciate the help.
     
  2. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #2
    try this:
    Code:
    ./a.out
    Notice the "./" before "a.out"

    HTH.
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    If you get bored of the ./ stuff then you need to add ./ to your PATH environment variable so the current directory will always be in the search path for executables. You can do this in your .profile, .cshrc or whatever.
     
  4. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #4
    I assume gcc assigns the correct execute permissions to the binary? If not, make sure you chmod that puppy...
     
  5. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #5
    Bah. That's too easy.
     

Share This Page