PDA

View Full Version : How do I make a CLI app executable from everywhere


cOle2
01-29-2002, 02:13 AM
I have an app that I've compiled and I want to be able to run it from anywhere instead of having to cd to the program directory.

I'm not quite sure what I have to do. Can anyone shed some light on this for me?

mervTormel
01-29-2002, 02:34 AM
so, you've compiled source, made object code, and linked it and now have an executable?

did you use project builder, or just the command line compiler/linker?

i think you might have a ways to go to make it a double-clickable OSX app.

let us know some more details about making this 'app'

pmccann
01-29-2002, 04:46 AM
Hi,

As long as the thing is executable (which, from your post, seems OK), and is visible to your shell through the PATH variable (that is, the executable sits in the top level of one of the directories listed when you enter "printenv PATH") then you should just be able to type the name, no matter what directory you're currently in.

eg Make a "bin" directory in your home directory if there's not one there already. Move your executable to that location. Type the word "rehash" to get the shell to scan through all of the directories in your PATH looking for executables to cache. (It does this when it starts up, and thus won't see anything added into the directories until you request a rescan this way.) And, well.... bingo.

If you don't want to, or can't move the thing, you can just add the directory in which the executable sits to your path. If it's in /this/funky/dir you can add this line to the end of your ~/.tcshrc or ~/.cshrc file (whichever you have: make one of them if you don't have one. Damn this was supposed to be short!).

setenv PATH ${PATH}:/this/funky/dir

Cheers,
Paul

cOle2
01-31-2002, 01:04 AM
Adding my programs directory to the path via my .tcshrc file worked beautifully.

Thanks for the help!