Reputation: 457
I want to create a binary file from a C file using ubuntu. I have done something like:
gcc -c ArrayError3.c -o ArrayError3.
This creates a file ArrayError3 on my Desktop. When I click on it, ubuntu tells me that there is no application installed for object files. I am very much a newbie to C and linux. Could anyone please advise me on how to solve this issue? Many thanks.
Upvotes: 0
Views: 1883
Reputation:
The problem is in
gcc -c
The -c switch makes GCC not link your code to an actual executable, only compiles it to an object file, which is not a "complete" format, it can't yet be run. Use just
gcc ArrayError3.c -o ArrayError3
instead.
Upvotes: 0
Reputation: 409442
You need to read more about what the arguments for GCC mean. The -c
option tells GCC to create an object file, not an executable file. This object file needs to be linked to create an executable file.
This is commonly used when you have several source files that needs to be linked together to form one executable. Example:
$ gcc source1.c -c -o source1.o
$ gcc source2.c -c -o source2.o
$ gcc source1.o source2.o -o exec
The solution for you it to simply not use the -c
option.
Upvotes: 0
Reputation: 182734
Just drop the -c
so it won't stop after making the object file. The -c
option tells gcc
not to run the linker. If omit it, gcc will make a full blown executable for you.
Upvotes: 1