GCC没有';我不想更改输出文件

GCC没有';我不想更改输出文件,gcc,compilation,Gcc,Compilation,似乎因为我安装了最新版本的GCC,如果我想更改输出文件,我就不能再编译任何C文件了。让我们举一个例子,filehello.c: #include <stdlib.h> #include <stdio.h> int main() { printf("hello\n"); } 它工作正常,我有a.out输出。但如果我想更改输出的名称,我基本上应该: gcc -o hello.c hello 我说得对吗 如果是,我会得到以下错误: gcc: error: hel

似乎因为我安装了最新版本的GCC,如果我想更改输出文件,我就不能再编译任何C文件了。让我们举一个例子,file
hello.c

#include <stdlib.h>
#include <stdio.h>

int main()
{
     printf("hello\n");
}
它工作正常,我有
a.out
输出。但如果我想更改输出的名称,我基本上应该:

gcc -o hello.c hello
我说得对吗

如果是,我会得到以下错误:

gcc: error: hello: No such file or directory
gcc: fatal error: no input files
compilation terminated
另一个例子是,它完全是WTF:

gcc -o Simplexe.c Simplexe
Simplexe: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
Simplexe: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here
Simplexe: In function `__data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o:(.data+0x0): first defined here
Simplexe:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
Simplexe: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here
Simplexe: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
Simplexe:(.dtors+0x8): first defined here
/usr/bin/ld: error in Simplexe(.eh_frame); no .eh_frame_hdr table will be created.
我从未见过这样的东西,它删除了我的源文件。我被抓过一次,我再也不会被抓了。

改变

gcc -o hello.c hello

-o
后面跟着目标,而不是源

第二种情况可能发生,如果目标
simpleexe
存在,现在gcc尝试再次将其链接到“target”
simpleexe.c
,但这只是猜测。

更改

gcc -o hello.c hello

-o
后面跟着目标,而不是源


第二种情况可能发生,如果目标
simpleexe
存在,现在gcc尝试再次将其链接到“target”
simpleexe.c
,但这只是猜测。

-o指定的输出文件,在您的情况下是hello.c,因此您正在尝试编译文件hello,它不存在。正确的命令是:

你好,c-o你好


-o指定的输出文件,在您的例子中是hello.c,因此您试图编译不存在的文件hello。正确的命令是:

你好,c-o你好


我觉得自己很笨,我对我的命令行很有信心。当然这是解决方案。但我努力了!我觉得自己很笨,我对我的命令行很有信心。当然,这就是解决办法。但我努力了!这是正确的,Simplexe文件存在,这就是它无法工作的原因。非常感谢这是正确的,Simplexe文件存在,这就是为什么它不起作用。谢谢
gcc -o hello hello.c