在64位Ubuntu上编译32位程序常见错误

问       题1: 找不到头文件 asm/errno.h

解决办法 : 【/usr/lib/gcc$ 】sudo ln -s x86_64-linux-gnu/asm asm

 

问题2:找不到gcc静态库,错误描述如下

~/tools/dnn-offline-htk-32/HTKTools$ gcc -o HBuild -m32 -ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH="x86_64"' -Wall -Wno-switch -g -I
../HTKLib -DPHNALG HBuild.c ../HTKLib/HTKLib.a -lm -L/lib/i386-linux-gnu -L/home/datadisk2/jfyuan223/tools/dnn-offline-htk-32/HTKTools/../GotoBLASLib -L /usr/lib/gcc/i686-linux-gnu -lgoto2 -lgfortran 
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

问题原因:没有安装32位gcc编译库

解决办法:第一步  查看gcc版本

/usr/lib/gcc/i686-linux-gnu$ gcc -v                                   
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) 

              第二步: 根据gcc版本安装对应的gcc

sudo apt-get install lib32gcc-4.7-dev

 

posted on 2018-04-21 16:35  袁军峰  阅读(1265)  评论(0编辑  收藏  举报

导航