Ninad
Ninad

Reputation: 31

C program, calling object file

I have written a simple helloworld.c program. I can compile it and run it on linux terminal using gcc and ./a.out command. My query is regarding calling .o file without any extension. For example, to run my program instead of typing "./helloworld.out", I want to run it using keyword "helloworld" on my terminal. Any hints???

Thank You.

Upvotes: 0

Views: 105

Answers (1)

P0W
P0W

Reputation: 47824

Just compile using

gcc -o helloworld helloworld.c

The -o option is for the output file name

Then use:

./helloworld

You need the ./ to tell the shell where the executable resides, since the current directory is unlikely to be in $PATH.

Upvotes: 2

Related Questions