Results 1 to 9 of 9

Thread: GCC Problems!

  1. #1


    Member Since
    Sep 08, 2009
    Posts
    5
    GCC Problems!
    I'm a student completely new to C++ Programing, and my instructor knows nothing about Macs, so Im doing this on my own. I downloaded all of Xcode and wrote a program on it. Now Im trying to compile it. From what i can glean off the internet, I suppose to go to my terminal (which by the way, I didnt know existed, so you understand my knowledge level) and type something like;

    gcc MP0temp.h

    MP0temp.h being the program I wrote

    Please Help!

    PS Im very new to programing so the plainer the english the better

    THANK YOU

  2. #2

    novicew's Avatar
    Member Since
    Jan 04, 2006
    Location
    Hamburg, Germany
    Posts
    1,385
    Specs:
    MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
    If it is a C++ file, you should save it with .cc extension. eg. hello.cc

    To run your first C++, just follow the following steps.
    1) Open a text editor and write your code.
    Eg.
    Code:
    #include <iostream>                                                                                                 
      2 int main()
      3  {
      4   std::cout << "Hello World!" << std::endl;
      5   return 0;
      6 }
    Save it as <file>.cc Eg. hello.cc in your Desktop.

    2) Open Terminal.app from /Applications/Utilities/ and type
    Code:
    cd Desktop
    and hit enter.

    3) To compile the file
    g++ <file>.cc -o <file> eg.
    Code:
    g++ hello.cc -o hello
    If your program is correct, this will create an executable file.

    4) To execute the program
    ./<file> eg.
    Code:
    ./hello

  3. #3


    Member Since
    Sep 08, 2009
    Posts
    5
    Ok, cool thanks Im ganna give that a try later. But whats all this talk about GCC. And will your way alert me to my errors?

  4. #4

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  5. #5


    Member Since
    Sep 08, 2009
    Posts
    5
    Makes sense

  6. #6


    Member Since
    Sep 08, 2009
    Posts
    5
    when i type ./MP0temp at the end it says no such directory or file

  7. #7


    Member Since
    Sep 08, 2009
    Posts
    5
    Oops nvm. worked perfectly. THANK YOU. saved my ***

  8. #8

    novicew's Avatar
    Member Since
    Jan 04, 2006
    Location
    Hamburg, Germany
    Posts
    1,385
    Specs:
    MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
    would you mind sharing the code you are trying to compile?

  9. #9

    novicew's Avatar
    Member Since
    Jan 04, 2006
    Location
    Hamburg, Germany
    Posts
    1,385
    Specs:
    MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
    glad it worked for you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hello World app takes 45s to start from the terminal, gcc, gdb and dtrace problems
    By Ethan asdf in forum OS X - Development and Darwin
    Replies: 5
    Last Post: 02-12-2009, 05:03 PM
  2. Gcc 4.2
    By olifu02@gmail.c in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 01-13-2008, 11:26 PM
  3. How to upgrade gcc 3 to gcc 4 intel mac
    By jonnyd in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 12-29-2007, 04:34 PM
  4. Gcc
    By Destructive in forum OS X - Apps and Games
    Replies: 2
    Last Post: 12-17-2007, 11:40 PM
  5. gcc and g++
    By fedesuarez in forum OS X - Operating System
    Replies: 4
    Last Post: 02-01-2006, 02:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •