在64位Ubuntu中构建一个32位应用程序 [英] Building a 32-bit app in 64-bit Ubuntu
问题描述
gcc -o xgap xcmds.o utils.o gapgraph.o gaptext.o pty。 o popdial.o xgap.o selfile.o -L / usr / lib32 -lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE
/ usr / bin / ld:跳过不兼容的/ usr /当搜索-lXmu
...
/ usr / bin / ld时,lib32 / libXmu.so:输入文件xcmds.o的i386体系结构与i386不兼容:x86-64输出
...
我已经安装了 ia32-libs 和 mutilib支持。我想我只需要强制链接器生成一个i386输出。我试着在我的gcc命令中放入两个 ld 标志,如上所示: -melf_i386 和 -oformat elf32-i386 。但是会发生什么情况是,gcc不再搜索 / usr / lib32 中的32位库。我想知道是否需要按照固定的顺序放置这些标志?
感谢您的任何想法和帮助!
编辑:当我添加-m32标志在我最后的gcc命令(即我认为的连接阶段)中,即使我有-L / usr / lib32标志,gcc也不会在/ usr / lib32中搜索(真的很奇怪...)和生成以下错误:
$ p $ / usr / bin / ld:跳过不兼容/ usr / lib / gcc / x86_64-linux-gnu /4.6.1/../../../libXaw.so当搜索-lXaw
时/ usr / bin / ld:在搜索-lXaw $ b时跳过不兼容的/usr/lib/libXaw.so $ b / usr / bin / ld:找不到-lXaw
collect2:ld返回1退出状态
任何人都知道为什么会发生这种情况?我正在使用自动工具进行配置和制作。我非常擅长修改这些脚本文件。
您需要使用 -m32
。
gcc -m32 -o xgap xcmds.o utils.o gapgraph.o gaptext。 o pty.o popdial.o xgap.o selfile.o -L / usr / lib32 -lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE
所有考虑的事情,我认为你应该能够在使用<$ c $时删除 -L / usr / lib32
c> -m32 。
After hours of googling, I decide to give up and ask you experts. I am trying to build a 32-bit application (xgap if anyone interested) in my 64 Ubuntu 11.10. I added the CFLAGS=-m32 and the LDFLAGS=-L/usr/lib32 in the makefile. The objects are built into 32 bit fine. The last step is to link all the objects and libraries for X windows into this executable---xgap. Somehow it keeps giving me this error:
gcc -o xgap xcmds.o utils.o gapgraph.o gaptext.o pty.o popdial.o xgap.o selfile.o -L/usr/lib32 -lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE
/usr/bin/ld: skipping incompatible /usr/lib32/libXmu.so when searching for -lXmu
...
/usr/bin/ld: i386 architecture of input file `xcmds.o' is incompatible with i386:x86-64 output
...
I have installed ia32-libs and mutilib support. I think I just need to force the linker to generate a i386 output. I tried to put two ld flags in my gcc command as shown above: -melf_i386 and -oformat elf32-i386. But what happens is that gcc doesn't search for the 32 bit library in /usr/lib32 anymore. I wonder if I need to put those flags in some fixed order?
Thanks for any idea and help!
EDIT: when I add the -m32 flag in my last gcc command (the linking stage I believe), even if I have the -L/usr/lib32 flag in place, gcc doesn't search in /usr/lib32 anymore ( really weird...) and generates the following error:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../libXaw.so when searching for -lXaw
/usr/bin/ld: skipping incompatible /usr/lib/libXaw.so when searching for -lXaw
/usr/bin/ld: cannot find -lXaw
collect2: ld returned 1 exit status
Any one has any idea why this happens? I am using the auto tool to configure and make. I am really good at modifying those script files.
You need to use link with -m32
as well.
gcc -m32 -o xgap xcmds.o utils.o gapgraph.o gaptext.o pty.o popdial.o xgap.o selfile.o -L/usr/lib32 -lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE
All things considered, I think you should be able to drop the -L/usr/lib32
when using -m32
.
这篇关于在64位Ubuntu中构建一个32位应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!