Results 1 to 5 of 5
  1. #1

    Member Since
    Apr 20, 2012
    Unhappy -bash g++:command not found
    "Newbie" question:
    I'm learning some C++ at university, so I installed Xcode on my mac in order to compile and run my small programs.
    There is absolutely no issue as long as I work within Xcode projects, that is to say writing and running "within Xcode".
    Instead, I can't manage to compile (and run) them directly from the terminal window because, if I type "g++ file_name.cpp", I get the answer "-bash g++ command not found"; the same happens with gcc.
    I thought that installing Xcode would provide me automatically with a proper compiler.

    Can you help me?
    PS: there are some similar threads but I couldn't find another user with exactly my same problem...

  2. #2

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    2012 13" MBP (2.5 i5, 8GB)
    If you're using a newer version of Xcode, you need to install the command line tools manually. In Xcode, go to Preferences > Downloads and install the "Command Line Tools" package.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  3. #3

    Member Since
    Apr 20, 2012
    Thank you for the prompt answer.
    I'm trying right now!

    it worked! thank you very much

    now I just have to do some practice...

  4. #4

    Member Since
    Apr 20, 2012
    Ok, now that I have a working g++, I would like to make a shortcut that compiles the .gpp file, renaming the o.out file in a given way; the problem is: I can't figure out the syntax.

    what I write: g++ my_file.cpp -o my_file
    what I'd like to write: --alias-- my_file.cpp

    thanks in advance

  5. #5

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Tucson, AZ
    Way... way too many specs to list.
    a quick bash script like this would work.

    in2=`echo $in1|tr -d '.cpp'`
    g++ $in1 -o $in2
    This machine kills fascists
    Got # ? phear the command line!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Learning the Command Line - Bash Prompts (1)
    By vansmith in forum OS X - Operating System
    Replies: 0
    Last Post: 04-15-2014, 06:45 PM
  2. Bash command not found
    By danipoak in forum OS X - Development and Darwin
    Replies: 10
    Last Post: 12-18-2013, 11:43 AM
  3. bash: make: command not found
    By yousemeti in forum OS X - Development and Darwin
    Replies: 9
    Last Post: 02-29-2012, 04:28 PM
  4. bash command window size
    By wfs123 in forum OS X - Operating System
    Replies: 0
    Last Post: 08-07-2011, 04:51 PM
  5. bash 'export' command not working
    By msae in forum OS X - Operating System
    Replies: 8
    Last Post: 07-05-2011, 11:55 AM

Posting Permissions

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