PDA

View Full Version : Problem with running an executable file



sshahir
September 6th, 2006, 09:05 PM
I am new in Linux environment, and I am trying to compile and run C programs through gcc compiler, and I face a problem with running an executable output file.

I have compiled a very simple “C program” by using “gcc HelloWorld.c -o test.out”

The result is an executable file “test.out”, but when I try to execute the file, I cannot.

>test.out <enter>

I appreciate for any comment regarding How to run the executable file.

Thanks,
Shahed

cstudent
September 6th, 2006, 09:08 PM
./test.out

croak77
September 6th, 2006, 09:14 PM
Or copy to /usr/bin or /usr/local/bin

sshahir
September 6th, 2006, 09:26 PM
I got it. Thanks a lot.

Regards,
Shahed

ifokkema
September 7th, 2006, 11:20 AM
The reason for this is that the current directory you're in, is not in the PATH environment variable.

Also, I recommend you don't put your files in /usr/bin, but in ~/bin, unless they're meant for general usage among more than one user. You can add ~/bin to your path by editing your ~/.bash_profile or ~/.bashrc. ~/.bash_profile has it preconfigured, you just need to uncomment it.