caf*_*caf 122
export CFLAGS=-m32
Run Code Online (Sandbox Code Playgroud)
and*_*dri 76
$ gcc test.c -o testc $ file testc testc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped $ ldd testc linux-vdso.so.1 => (0x00007fff227ff000) libc.so.6 => /lib64/libc.so.6 (0x000000391f000000) /lib64/ld-linux-x86-64.so.2 (0x000000391ec00000) $ gcc -m32 test.c -o testc $ file testc testc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped $ ldd testc linux-gate.so.1 => (0x009aa000) libc.so.6 => /lib/libc.so.6 (0x00780000) /lib/ld-linux.so.2 (0x0075b000)
简而言之:使用-m32
标志来编译32位二进制文件.
另外,请确保安装了所有必需库的32位版本(在我的情况下,我在Fedora上需要的只是glibc-devel.i386)
Nat*_*one 16
在CMake的更高版本中,在每个目标上执行此操作的一种方法是:
set_target_properties(MyTarget PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
我不知道在全球范围内做到这一点的方法.
一种方法是设置chroot环境.Debian有很多工具,比如debootstrap
对于任何复杂的应用程序,我建议使用lxc容器.lxc容器是'在类固醇上的chroot和完全成熟的虚拟机之间的中间'.
例如,这是在Ubuntu Trusty系统上使用lxc构建32位wine的方法:
sudo apt-get install lxc lxc-templates
sudo lxc-create -t ubuntu -n my32bitbox -- --bindhome $LOGNAME -a i386 --release trusty
sudo lxc-start -n my32bitbox
# login as yourself
sudo sh -c "sed s/deb/deb-src/ /etc/apt/sources.list >> /etc/apt/sources.list"
sudo apt-get install devscripts
sudo apt-get build-dep wine1.7
apt-get source wine1.7
cd wine1.7-*
debuild -eDEB_BUILD_OPTIONS="parallel=8" -i -us -uc -b
shutdown -h now # to exit the container
Run Code Online (Sandbox Code Playgroud)
这是关于如何使用lxc在64位主机上构建32位wine的Wiki页面.