Help in C programming in Linux
Hi there.
I just wrote my first C prg in Linux (let's call it sample.c).... How can I compile it? Thanks. |
try this:
Code:
gcc -o sample sample.c |
Hi Patrick. I tried the gcc command you suggested, there are no errors and it built the program called sample. however, when I excute sample from the prompt it tells me that "sample: command not found"... I do not see the object file though, should it create a file called "sample.o"? Thanks.
|
./sample
if you are in the same directory |
Ok, that helped. thanks Dive
Ok, that helped. thanks Dive
|
the reason that you dont see the .o files or all the other stuff usially created with a compiler is that GCC by default ether pipes output between processes or deletes the files afterwards,
if you need the filles for somthing there is an option to keep them try man gcc for more details |
Code:
gcc -c ... Code:
gcc -o prog ... You can give both .c files (that will be compiled) and .o files (previously compiled) as input for the linking. Note that the "-o prog" is optional. If you don't specify the name of the output program that is to be created, it will be named "a.out" by default. I suggest you read up on Makefiles and the "make" command too. |
All times are GMT -5. The time now is 08:23 PM. |