使用 GCC 编译 32 位程序时出现奇怪的错误

Weird error when compiling 32-bit programs with GCC

当我尝试在 64 位 Linux 上使用 GCC 编译简单的 32 位 C 程序时,我收到以下消息:

[teo.samarzija@teos-acer-laptop debug]$ gcc -m32 -o program program.c
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: skipping incompatible /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.3.1/libgcc.a when searching for -lgcc
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: skipping incompatible /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.3.1/libgcc.a when searching for -lgcc
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: skipping incompatible /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.3.1/libgcc.a when searching for -lgcc
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: skipping incompatible /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.3.1/libgcc.a when searching for -lgcc
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.3.1/32/libgcc.a(_muldi3.o): unable to initialize decompress status for section .debug_info
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: i386:x86-64 architecture of input file `/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.3.1/crtbegin.o' is incompatible with i386 output
/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: i386:x86-64 architecture of input file `/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.3.1/crtend.o' is incompatible with i386 output
collect2: error: ld returned 1 exit status

我该怎么办?

,GPS好像是用GCC编译的,不支持multilib。如果你 运行 gcc -v,你会注意到输出中提到的 --disable-multilib 选项。

那我想你运气不好。您要么必须自己构建 GCC,要么从与 GPS 无关的其他来源安装它:例如来自 Linux 发行版的存储库。然后你必须以某种方式告诉 GPS 使用这个其他版本的 GCC。