View Full Version : Cannot run linked program

20th November 2008, 02:55 AM
Using the source of a program on a DVD about assembly programming, I compiled and linked a program which I called "sample" The program shows up on the desktop and is listed as an executable file. When I run it from the terminal, it says "command not found" even though I am in the correct directory and "dir" lists it. What am I doing wrong?


20th November 2008, 02:58 AM
We need a litle more to go by than that. Do you have to be root to run the program? I'm thinking you don't have to but what does the program do? In order to help anyone can't really help if we don't know what it does. Paste the source code on here if you want, you shoulnd't get maimed for it just maybe a slap on the wrist if it's in the wrong area :D

20th November 2008, 03:10 AM
It is a simple first program in the book. The version I uploaded (I hope) just asks for user input then prints a reply. I pasted it in the x86_64 area, but it double spaced everything. I hope that calling it an attachment is what I should have done.


20th November 2008, 03:29 AM
What am I doing wrong?
You're thinking Windows. Linux is not Windows. Linux is Linux and it doesn't act like Windows.
In windows, the first place the system looks for a command is in the current directory. If not there, it uses the $PATH variable to search in the defined paths. In Linux, it only uses the $PATH variable.

To properly link your program, you must specify an explicit path to it, or at least put it in a directory that is in the defined $PATH statement. In programming or scripting, an explicit path is always best.

If I put an executable file in my home directory, and I am in that directly, and I type the files name to run it, bash will tell me: command not found. That's because my home directly is not in bash's search path. In that case, I would prepend "./" to the filename: ./myprogram

That tells bash to "look here in this directory" for myprogram.

20th November 2008, 03:40 AM
T H A N K Y O U ! ! !

Yes, you are correct. I can run the program now.

Judging from the number of posts you have made, you are a real asset to the forum!