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.

Help with gcc


Post Reply New Thread Subscribe

 
Thread Tools
avalanche

 
Member Since: Jun 11, 2008
Posts: 5
avalanche is on a distinguished road

avalanche is offline
Hi, so I've used gcc on Unix before and had no problems but on my mac (10.4) I can't get it to work. I've installed xcode and the developer tools. The thing is that gcc compiles the code perfectly fine, but I can't run it. So on unix for example I would do something like this:

gcc -o test test.c

and then to run it:

test <inputs>

but on the mac it give me an error "test: command not found" but it creates the executable "test" when I compile it. I'm sure there is something obvious I'm missing here, can someone help me out?

Thanks.
QUOTE Thanks
mystic_fm

 
Member Since: Mar 15, 2007
Posts: 161
mystic_fm will become famous soon enough
Mac Specs: 17" MacBook Pro, 2.33GHz C2D, 2GB RAM

mystic_fm is offline
My bet is that the current directory is not a part of your PATH environment variable. If so, one workaround is to run the program this way:

./test <inputs>

You can check what your default executable search path is set to with the following command:

env | grep "^PATH="
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
echo $PATH

also works

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

 
Member Since: Jun 11, 2008
Posts: 5
avalanche is on a distinguished road

avalanche is offline
Yep, that was it, thanks guys.
QUOTE Thanks
avalanche

 
Member Since: Jun 11, 2008
Posts: 5
avalanche is on a distinguished road

avalanche is offline
Actually guys can you tell me what to add to my PATH to fix this, I've been messing around with my .profile but I still can't manage to fix it.

Thanks
QUOTE Thanks
mystic_fm

 
Member Since: Mar 15, 2007
Posts: 161
mystic_fm will become famous soon enough
Mac Specs: 17" MacBook Pro, 2.33GHz C2D, 2GB RAM

mystic_fm is offline
Assuming that you are using the default bash shell, if you are creating the ".profile" file you mentioned in your home directory (i.e., "echo $HOME") and adding the following single line to it:

PATH=$PATH:.

... that ought to do it.

One other note about specifically using the name "test": you probably have an executable file named "test" that is part of your OS (in the /bin directory). This file is used for checking various conditions inside shell scripts. Adding the current directory to your PATH as shown above won't help with this specific name because the /bin directory will be searched first. This is exactly why I suggested using the explicit path ./test, since specifying a path preempts any such searching. Alternatively, you could put the current directory at the front of the PATH instead of at the tail end to force the current directory to be searched before all system directories, but I don't think that's a good idea.
QUOTE Thanks
avalanche

 
Member Since: Jun 11, 2008
Posts: 5
avalanche is on a distinguished road

avalanche is offline
Ok that did it, thanks a lot. And I'm not actually using test as the file name, I just used it as an example, but thanks for letting me know that, I probably would have made that mistake at some point and not been able to figure it out.
QUOTE Thanks

Post Reply New Thread Subscribe


« Core Audio AudioQueueEnqueueBufferWithParameters | New to Mac - About development »
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 compiling jdgti OS X - Development and Darwin 5 09-20-2006 05:08 AM
How to install GCC version 4.xx???? Philipina OS X - Development and Darwin 1 04-14-2006 11:25 AM
gcc and g++ fedesuarez OS X - Operating System 4 02-01-2006 03:50 PM
gcc compiler, no stdio.h found lzco OS X - Development and Darwin 6 10-21-2005 05:23 PM
GCC error the_jesus OS X - Development and Darwin 0 07-17-2004 08:04 PM

All times are GMT -4. The time now is 11:43 PM.

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?