【发布时间】:2011-07-19 23:49:25
【问题描述】:
我正在使用自动工具来构建我的系统,该系统主要由一个库组成。在 64 位 Red Hat 平台上,我需要能够生成一个能够在 32 位 Red Hat 平台上工作的库。
当我将 -m32 添加到编译行时,一切正常,可以生成静态 (.a) 库,但是一旦我尝试创建共享库,就会收到如下错误:
/usr/bin/ld: warning: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crti.o' is incompatible with i386 output
/usr/bin/ld: warning: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbeginS.o' is incompatible with i386 output
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbeginS.o: In function `__do_global_dtors_aux':
crtstuff.c:(.text+0x29): undefined reference to `__DTOR_END__'
collect2: ld returned 1 exit status'
我可以看到问题在于它包含来自 /usr/lib64 的 64 位目标文件,而不是来自 /usr/lib 的正确 32 位目标文件(它们在那里没问题),但我不能弄清楚如何解决它。
【问题讨论】:
-
你弄错了 crti.o 请参阅this previous question about inspecting the include path。你确定你的库路径中有 32 位 crti.o 吗? (并且它在 64 位版本出现之前就存在于路径中。)
-
据我所知,包含路径内置在编译器/链接器中。由于我想根据 autotools 配置脚本的参数构建 32 位或 64 位版本,因此无法重新构建工具。我也需要这个才能在我的客户机器上工作。
-
你真的安装了 32 位 glibc-devel 吗?
标签: shared-libraries autotools