Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to run a compiled UNIX application UNIX
[Editor's note: See the comments for the answer]

I built a hello world simple application that built great. That simply means that it compiled. I did this in my home directory in a terminal application. It compiles to a.out. When I try to run this application it says I cannot find a.out. Any clues on how I can make this work?
  • Currently 3.40 / 5
  You rated: 2 / 5 (5 votes cast)

How to run a compiled UNIX application | 3 comments | Create New Account
Click here to return to the 'How to run a compiled UNIX application' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
permissions and PATH
Authored by: Anonymous on Apr 03, '01 07:24:33AM

Likely what's happening is weirdness in your path, or permissions problems.
Do an ls -laF a.out from the directory that the file's in.
If it looks like:
-rw-r--r-- 1 user group 140 Apr 2 22:23 a.out

Then it's not executable. That's easy to fix. Type chmod 755 a.out and try it again.

Still having problems? It's probably a PATH problem. Try running it by typing ./a.out instead. (The ./ tells it to check your current directory for it.)

Hope this helps.

[ Reply to This | # ]
permissions and PATH
Authored by: Anonymous on Apr 03, '01 10:54:27AM

Thanks for the responses. The permissions where good. What did the trick was running it with the ./a.out in front.

Thanks again.


[ Reply to This | # ]
related tips
Authored by: robh on Apr 03, '01 08:33:16AM

As 'Ciannait' pointed out, running it with "./a.out" ought to do the trick.

Note that if you're thinking of putting "./" into your default path, DON'T. It's considered a security weakness to be able to run executables in the current directory without explicitly identifying them with the directory path or "./".

If you move the executable into ~/bin (aka /Users/Myname/bin) you might be surprised to find that the shell (tcsh) can't find it even though ~/bin is in your path (printenv PATH). The problem here is that the contents of the directories in your path were cached when the shell started, so you need to run "rehash" first to refresh the cache.

If you are creating your own command line executables then it's a good idea to keep them in ~/bin so that you can run them from any directory without giving the full path.

[ Reply to This | # ]