gpt4 book ai didi

c - gcc 在一个小小的 hello world 程序中返回大量错误

转载 作者:行者123 更新时间:2023-12-01 11:48:01 26 4
gpt4 key购买 nike

我有点难过。这是我从 gcc 得到的错误

gcc -lm -g -o bin/tomashell obj/tomashell.oobj/tomashell.o: In function `_start':(.text+0x0): multiple definition of `_start'/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invalid symbol index 12/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invalid symbol index 12/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 21 has invalid symbol index 14/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 22 has invalid symbol index 22/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_line): relocation 0 has invalid symbol index 2/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:/build/buildd-eglibc_2.11.2-10-i386-GapcyD/eglibc-2.11.2/csu/../sysdeps/i386/elf/start.S:119: first defined hereobj/tomashell.o:(.rodata+0x0): multiple definition of `_fp_hw'/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:(.rodata+0x0): first defined hereobj/tomashell.o: In function `_fini':(.fini+0x0): multiple definition of `_fini'/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crti.o:(.fini+0x0): first defined hereobj/tomashell.o:(.rodata+0x4): multiple definition of `_IO_stdin_used'/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined hereobj/tomashell.o: In function `__data_start':(.data+0x0): multiple definition of `__data_start'/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:(.data+0x0): first defined hereobj/tomashell.o: In function `__data_start':(.data+0x4): multiple definition of `__dso_handle'/usr/lib/gcc/i486-linux-gnu/4.4.5/crtbegin.o:(.data+0x0): first defined hereobj/tomashell.o: In function `_init':(.init+0x0): multiple definition of `_init'/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crti.o:(.init+0x0): first defined here/usr/lib/gcc/i486-linux-gnu/4.4.5/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'obj/tomashell.o:(.dtors+0x4): first defined herecollect2: ld returned 1 exit statusmake: *** [bin/tomashell] Error 1

And this is my entire code file:

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

int main()
{
printf("Hello, world!");
}

我完全不知道为什么这没有编译。我正在编译所有其他 C 应用程序。

最佳答案

obj/tomashell.o 不是目标文件而是可执行文件。您可能在编译时忘记使用 -c,因此(默认情况下)gcc 输出可执行文件而不是目标文件。

关于c - gcc 在一个小小的 hello world 程序中返回大量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7681110/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com