Discussion in 'Mac Programming' started by Doug.Mellon, Mar 26, 2006.

  1. macrumors newbie

    Mar 26, 2006
    I am new to mac C++ programming and have a quick question... I created a simple program that I want to execute in terminal. I was wondering what file I click on to do this? I have the C++ xCode project saved on my desktop so I went in that and cant find the executable. I have tried a bunch of diffrent stuff but it keeps opening in xCode.
    Any help would be awsome!
    Thanks in advance,

    EDIT: I was also wondering how you can get somthing to beep continusly?
  2. macrumors 6502a


    Sep 22, 2005
    Chicago, IL
    Sounds like you're really making an application that is simply a joy to use... :rolleyes:
  3. thread starter macrumors newbie

    Mar 26, 2006
    hahaha... no no, that doesnt have to do with my app haha. Just wanted to know for fun.
  4. macrumors 6502a

    Jun 17, 2003
    Open the terminal, then run the executable that is in the build/Debug directory of your XCode project.

    If this program is to be run from the terminal then a control-G character (ascii code decimal 7) will make the terminal beep. Put that into a loop:

    while(0) {
        printf("%c\n", 7);
  5. thread starter macrumors newbie

    Mar 26, 2006
  6. thread starter macrumors newbie

    Mar 26, 2006
    ok... this may sound really dumb but hang with me. I opened terminal and went file -> open -> and it wouldnt let me open the executable... then relized i prob. had to type somthing in, in the terminal itself. If this is the case what would I type...
    thanks for being patient.
    ~ Doug
  7. macrumors 6502a

    Jun 17, 2003
    I would suggest that if you don't know how to use the terminal shell then you should either first learn how to use the shell, or try to write a different type of program.

    You will need to change directory to the folder in which the executable resides and then type in the name of the executable.
  8. macrumors 6502a


    Oct 15, 2005
    If you're just writing simple one-file programs, which I assume you are doing now, just code your program in a text editor (such as Smultron) and then use CPP Edit to compile it. I've been using this combination for a while now, since I'm only writing simple programs at the moment. Once I get into programs with additional headers and stuff I'll move over to Xcode.
  9. thread starter macrumors newbie

    Mar 26, 2006
    Cool thanks alot for the help guys...

    ill try that out.
  10. macrumors 6502

    Apr 16, 2003
    Boston, MA
    The best way to learn how to code is to become familiar with the terminal, and use a simple text editor to get started.

    save the file as [filename].cpp, then just use g++ -o [filename] [filename.cpp]

    ./filename will then run the exec.


Share This Page