Results 1 to 4 of 4
Hi,
I thought this question's best category would be in the newbie section.
Basically I have a C code, (for simplicity is only prints a few lines), called printx.c that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-01-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
converting C code into command line executable
Hi,
I thought this question's best category would be in the newbie section.
Basically I have a C code, (for simplicity is only prints a few lines), called printx.c that I would like to convert into a binary file so whenever I have to type "printx" in the command line it would execute the program
ofcourse gcc will give me a binary file if I do a "gcc printx.c", but even the output file (e.g. print.out) would have to be executed in the following manner
./print.out
I only ask, because I notice programs like mailx (which is written in C) is a binary file that could be run in this manner (at least that's what I notice on my ubuntu distro)
- 09-01-2010 #2Linux Newbie
- Join Date
- Apr 2007
- Posts
- 119
If you look at the options available with gcc, it will tell you that there is an option to name the output binary whatever you want.
You can use "man gcc" to look it up.
- 09-01-2010 #3
I reckon that you don't wish to type the trailing "./" when you start your program.
Ok, here is the deal: When you type in a command with "./", the shell interpreter looks for the given program in a set of certain directories. These directories are determined by the PATH shell variable. Separated by ":"
to see them.Code:echo $PATH
This PATH variable can be adjusted to include your own directories, or even the "current" directory. Look it up in the bash manual.
What I do is creating a "bin" directory in my $HOME folder and append ":$HOME/bin:" to the variable. Then I put all my personal programs in this directory.Debian GNU/Linux -- You know you want it.
- 09-01-2010 #4Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
yep, I guess that's what I was looking for
Thanks


Reply With Quote
