当前位置: 技术问答>linux和unix
Hello.C的问题
来源: 互联网 发布时间:2016-07-15
本文导语: On Sun, 26 Dec 1999, Thomas Singleton [Eidos] wrote:> hello,> in order to follow a book's test procedure to see if the compiling/linking> of C programs work, i created a hello.c> file with the famous 'printf("Hello World!");' then (always followi...
On Sun, 26 Dec 1999, Thomas Singleton [Eidos] wrote:> hello,> in order to follow a book's test procedure to see if the compiling/linking> of C programs work, i created a hello.c> file with the famous 'printf("Hello World!");' then (always following the> instructions) did :> $gcc -c -Wall -D_GNU_SOURCE hello.c -o hello.o> then> $gcc -c hello.o hello.c> which reported :> gcc: hello.o : linker input file unused since linking not done> > i made a search for that message on gcc.gnu.org, and found a few linked> messages but they were all about merging two or more source into the same> object which is not my case, so i decided to post this
答案如下:(我看不懂)。
The message that gcc reported is correct. When you supply a library(even a compiled object file like you did) to a command that does nolinking (gcc -c), gcc simply informs you that the library was not usedbecause no linking was done. You didn't ask it to. Since you specified-c, "source" files are going to be compiled into .o object files, NOT intoan executable, nor is anything going to be done with any object files. Gccsaw the extraneous object file supplied and simply ignored it.
我发帖问了,但是怎么就是一个gcc -c hello hello.c呢?感觉一点都没有严谨,结果报错。
答案如下:(我看不懂)。
The message that gcc reported is correct. When you supply a library(even a compiled object file like you did) to a command that does nolinking (gcc -c), gcc simply informs you that the library was not usedbecause no linking was done. You didn't ask it to. Since you specified-c, "source" files are going to be compiled into .o object files, NOT intoan executable, nor is anything going to be done with any object files. Gccsaw the extraneous object file supplied and simply ignored it.
我发帖问了,但是怎么就是一个gcc -c hello hello.c呢?感觉一点都没有严谨,结果报错。
|
hello表示输出文件
hello.c输入文件
hello.c输入文件
|
弱弱的问问:你为什么要用gcc -c hello hello.c
而不是gcc -o hello hello.c
而不是gcc -o hello hello.c
|
人家是 gcc -c hello.o hello.c
或者 gcc -o hello hello.c
-c表示编译成目标文件
或者 gcc -o hello hello.c
-c表示编译成目标文件
|
gcc -o hello hello.c
生成exe文件
生成exe文件