LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Compiling a single source file: (https://www.linuxquestions.org/questions/programming-9/compiling-a-single-source-file-402086/)

hardstyleFX 01-11-2006 11:55 AM

Compiling a single source file:
 
Hello!

I Would like to know how to compile a single source file using GCC.
I have written programs in Windows, but in the future I want to do that in Linux.

Matir 01-11-2006 12:19 PM

Code:

gcc -o EXECUTABLE file.c

hardstyleFX 01-11-2006 01:01 PM

Thanks alot.

bigearsbilly 01-12-2006 05:01 AM

or:
(e.g: example.c)

make example

hint: don't call files 'test' there's a command of the same name.

Wim Sturkenboom 01-12-2006 05:19 AM

Quote:

Originally Posted by Matir
Code:

gcc -o EXECUTABLE file.c

Suggest to add the -Wall option
Code:

gcc -Wall -o EXECUTABLE file.c
Quote:

Originally Posted by bigearsbilly
or:
(e.g: example.c)

make example

hint: don't call files 'test' there's a command of the same name.

Does not work if he does not have a makefile :)
Your hint is correct, it fooled me a couple of times :(

bigearsbilly 01-12-2006 05:29 AM

Quote:

Originally Posted by Wim Sturkenboom
Does not work if he does not have a makefile :)

I'm sorry Wim, but I'm afraid you are WRONG. ;)
Implicit make rules are in force.

as I said

make example will work
observe:
Code:

touch example.c
make example
cc    example.c  -o example


Wim Sturkenboom 01-12-2006 06:05 AM

Never to old to learn :study:

bigearsbilly 01-12-2006 06:09 AM

surprising how few people know about it!
It's dead useful
:)


All times are GMT -5. The time now is 08:17 AM.