Click to See Complete Forum and Search --> : I can't run my compiled C program
mmagos
10-03-2000, 01:27 PM
Can somebody please help me, after I compile my C program and makes me the a.out, I can't make it run. I change the name and keeps telling me this error "bash: a.out: command not found". What is it, do I have to add another command so it can run or do I lack of a program that I didn't install. I would appreciate the help.
TheLinuxDuck
10-03-2000, 01:31 PM
When running a binary from the current directory, you'll need to use the ./ before the name, such as:
./a.out
Just FYI, when you compile the program, you can name the binary by using the -o option:
gcc programname.c -o programname
http://www.linuxnewbie.org/ubb/smile.gif Hope that helps!
------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq
witman
10-03-2000, 01:31 PM
Try:
./a.out
if that doesn't work, make sure you've got the permissions set to executable.
I got beat out by TheLinuxDuck!! Doh!!! http://www.linuxnewbie.org/ubb/biggrin.gif
------------------
Use the source!
The WITMAN Cometh!
[This message has been edited by witman (edited 03 October 2000).]
bakerb
10-03-2000, 06:13 PM
if typing ./a.out works, add this line
export PATH=.:$PATH
to the end of you .bashrc file (in your home directory)
The problem is that linux didn't know to look in the current directory, so we changed the path to tell it to look in the current directory first.
Keep on rockin' in the free world . . .
------------------
Save the whales. That way, you can collect and trade them with your friends!
Strike
10-03-2000, 06:33 PM
I'd do
export PATH=$PATH:. instead of the other way around. That way you don't accidentally run some script in your own directory thinking it's something else.
linuxduh
12-11-2000, 03:29 AM
hmm
say for example i would like to add a path to the compiler and env for it as well in the bash how do i do that?
what exactly will it look like in the file if there is already a default path entry? do we add to that same line and end with :. or another line ? What abt the environmnet?
how do we add the environment?
thanks
linuxduh
Originally posted by Strike:
I'd do
export PATH=$PATH:. instead of the other way around. That way you don't accidentally run some script in your own directory thinking it's something else.