分页: 1 / 1

[求助]gcc -og * *.c错误

发表于 : 2010-03-10 9:22
zwh198740
本想用gdb调试程序,结果-g编译时出现如下错误:
test64: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o:(.text+0x0): first de
fined here
test64:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o:(.rodata+0x0): first
defined here
test64: In function `_fini':
/build/buildd/glibc-2.7/build-tree/i386-libc/csu/crti.S:41: multiple definitio
n of `_fini'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crti.o:/build/buildd/glibc-2
.7/build-tree/i386-libc/csu/crti.S:41: first defined here
test64:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o:(.rodata.cst4+0x0): f
irst defined here
test64: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o:(.data+0x0): first de
fined here
test64: In function `__data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i486-linux-gnu/4.2.4/crtbegin.o:(.data+0x0): first defined here

test64: In function `_init':
/build/buildd/glibc-2.7/build-tree/i386-libc/csu/crti.S:15: multiple definitio
n of `_init'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crti.o:/build/buildd/glibc-2
.7/build-tree/i386-libc/csu/crti.S:15: first defined here
/tmp/ccweHNjO.o: In function `c_fun':
test64.c:(.text+0x0): multiple definition of `c_fun'
test64:(.text+0x84): first defined here
/tmp/ccweHNjO.o: In function `main':
test64.c:(.text+0x3f): multiple definition of `main'
test64:(.text+0xc3): first defined here
collect2: ld 返回 1
上面说我多次定义了这个那个。。。

同时gcc -o * *.c编译是可以通过的

怎么回事?怎么解决?

Re: [求助]gcc -og * *.c错误

发表于 : 2010-03-10 10:16
i_NIX
gcc -g *.c -o *.exe
其中,*.exe是生成的可执行程序。gcc的参数不要乱加, -o -g要分开

Re: [求助]gcc -og * *.c错误

发表于 : 2010-03-10 11:40
zwh198740
很感谢NIX的帮助,确实可以gdb了
不过之前我已这样用过很多次,都没有出现任何情况
最近更新过系统后,就开始出错了
再次感谢

Re: [求助]gcc -og * *.c错误

发表于 : 2010-03-10 12:53
i_NIX
不客气。
不同版本可能有差别。

Re: [求助]gcc -og * *.c错误

发表于 : 2010-03-22 15:06
rediscover
每次新版gcc都比以前有更严格的标准和规范。