|
|
Help with getting executables to run. Hi, I' new to grex and the other day I was playing with cc and I couldnt get my executables to run. I compiled my *small* program and renamed the out and typped the program name to run it....no go, it says command not found. I'm using the tcsh shell. do I need to change the permissions or something? Uro
17 responses total.
Since your current dir is probably not in your path, you need to specify a path to your program. You want something like ./pgmname argument arg2 ... Possibly the permissions are wrong, but unlikely. Check using ls -l; if you don't have execute access, chmod 700 pgmname will do it.
Yep, I had the exact same problem when I started, it drove me batty.
This response has been erased.
This response has been erased.
I've heard it's reasonable to put your current directory (i.e. ".") at the end of your path. Then if you type "ls" you'll find the real ls before you ever get to anything bogus. It's a pain not to be able execute programs where you are currently located...
I recommend creating a ~/bin directory and putting that on your path. Then instead of typing mv a.out program, just type mv a.out ~bin/program. ~/bin should go first on your path so you can override things. (For sh users, ~/bin is $HOME/bin)
Right, bin directory is the way to go.
It's generally safe (as safe as it gets) to put your home dir (or any other) in your path if you set the permissions thereto so as to make sure no one else can create files there (and set the executables so that no one can modify them).
Thanks for the help. I made a bin dir. Works fine.
This response has been erased.
So you make the compiler do the mv call instead of doing it yourself? (I've often wondered why that a.out thing is the default behavior. Bleah.)
Sure, make the compiler put that object code/binary into a file with a meaningful name...beats hell out of overwriting all your previous a.out... (You'd think it would be called c.out since it's a C compiler).
According to Libes and Ressler's book _Life with Unix_, a.out stands for Assembler OUTput. This makes sense, since the Unix C compiler generates assembly language output, then calls on the assembler to generate the binary object code.
This response has been erased.
You can often get a clue to that by typing "strings a.out", which will display all the ascii strings that are in the file.
Yes, I knew why it's "a.out". What I wondered is why this is still the *default* behavior. Bleah, I say again.
Because most people use "make" for any kind of serious Unix software development. The only reason to run "cc" straight is for some kind of trivial hack that probably doesn't deserve preservation, and therefore it's not a big deal to call it "a.out".
Response not possible - You must register and login before posting.
|
|
- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss