New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

-bash g++:command not found


Post Reply New Thread Subscribe

 
Thread Tools
Brightsun

 
Member Since: Apr 20, 2012
Posts: 3
Brightsun is on a distinguished road

Brightsun is offline
"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...
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,893
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is online now
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
QUOTE Thanks
Brightsun

 
Member Since: Apr 20, 2012
Posts: 3
Brightsun is on a distinguished road

Brightsun is offline
Thank you for the prompt answer.
I'm trying right now!

edit:
it worked! thank you very much

now I just have to do some practice...
QUOTE Thanks
Brightsun

 
Member Since: Apr 20, 2012
Posts: 3
Brightsun is on a distinguished road

Brightsun is offline
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
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
a quick bash script like this would work.


Code:
#!/bin/bash
in1=$1
in2=`echo $in1|tr -d '.cpp'`
g++ $in1 -o $in2

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks

Post Reply New Thread Subscribe


« Pygame won`t install on Mac OS X Lion | gfortran and g77 on lion »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
gcc command not found frike OS X - Development and Darwin 7 05-16-2011 10:50 AM
Airport Card Not Found - iBook G4 legusta5 Internet, Networking, and Wireless 4 04-13-2011 11:42 AM
Auto-Logging BASH session quietly danjmwalker OS X - Development and Darwin 0 10-04-2007 02:19 PM
iWork 08 image not found??? localfruit OS X - Apps and Games 0 08-09-2007 06:26 PM
Using cc in darwin: command not found. olav OS X - Development and Darwin 2 03-28-2006 03:31 AM

All times are GMT -4. The time now is 09:17 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?