CentOS x86_64上编译32位demo程序
来源:互联网 发布:怎样导出数据库 编辑:程序博客网 时间:2024/05/17 18:27
先写个hello world的简单程序
gcc -m32 a.c
先确保a.c能够编译链接成功,再去编译你的32位程序。
[root@localhost ~]# gcc -m32 hello.c
In file included from /usr/include/features.h:399:0,
from /usr/include/stdio.h:27,
from hello.c:1:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
# include <gnu/stubs-32.h>
^
compilation terminated.
[root@localhost ~]#
编译失败,缺少32位头文件。
使用yum安装i686的库
[root@localhost centos-release]# yum list glibc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
glibc.i686 2.17-55.el7 @base
glibc.x86_64 2.17-55.el7 @anaconda
[root@localhost centos-release]# yum install glibc.i686
yum安装时有个小插曲,提示GPG keys配置有问题:
The GPG keys listed for the "CentOS-7 - Base - 163.com" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
解决方法:
手动从163网站导入CentOS-7的key,我的版本是CentOS 7。
rpm -import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
安装glibc开发库:
[root@localhost ~]# yum list *glibc*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
compat-glibc.x86_64 1:2.12-4.el7.centos @anaconda
compat-glibc-headers.x86_64 1:2.12-4.el7.centos @anaconda
glibc.i686 2.17-55.el7 @base
glibc.x86_64 2.17-55.el7 @anaconda
glibc-common.x86_64 2.17-55.el7 @anaconda
glibc-devel.x86_64 2.17-55.el7 @anaconda
glibc-headers.x86_64 2.17-55.el7 @anaconda
Available Packages
glibc-devel.i686 2.17-55.el7 base
glibc-static.i686 2.17-55.el7 base
glibc-static.x86_64 2.17-55.el7 base
glibc-utils.x86_64 2.17-55.el7 base
[root@localhost ~]# yum install glibc-devel.i686
再次编译,发现编译成功,但是链接失败。
[root@localhost ~]# gcc -m32 hello.c
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
[root@localhost ~]#
缺少动态库libgcc
[root@localhost ~]# yum list libgcc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
libgcc.x86_64 4.8.2-16.el7 @anaconda
Available Packages
libgcc.i686 4.8.2-16.el7 base
[root@localhost ~]# yum install libgcc.i686
libgcc安装成功后,再次编译
[root@localhost ~]# gcc -m32 hello.c
[root@localhost ~]# ./a.out
hello world
发现编程链接全部成功,OK,大功告成。
- CentOS x86_64上编译32位demo程序
- X86_64机器编译32位程序
- X86_64机器编译运行32位程序
- Hadoop在CentOS 6.6-x86_64上编译
- 在64位的CentOS上编译32位的程序
- 在64位linux上编译32位程序
- 64位Centos6.0上编译32位程序
- 64位机器上 编译32位程序
- 64位Ubuntu上编译32位程序操作步骤
- 64位Ubuntu上编译32位程序
- centos 7 已经支持 gcc 编译32位程序
- CentOS 64位上编译 Hadoop2.6.0
- Fedora 21 x86_64 上运行32位软件
- ubuntu 64上的GCC如何编译32位程序
- 64位redhat编译执行32位c++程序(redhat安装centos源)
- centos 7 x86_64 与 centos 7 32位系统安装的注意事项
- centos兼容32位程序
- 为什么gcc在64位Solaris上编译出来的程序默认是32位的?
- 【新手】DevExpess的GridView嵌套表格
- POJ 2502 Subway(Floyd单源最短路)
- 用poi框架进行批量导入导出实例
- PPTP、L2TP、IPSec和SSL VPN 的区别
- Edit Distance @leetcode
- CentOS x86_64上编译32位demo程序
- Linux字符设备与块设备的区别与比较
- 浙江一副县长辞官 辞职感言:可以长长地舒口气了
- QT 国际化扩展所感 an extending QT Translator (自己实现翻译逻辑,编辑更方便)
- wordpress作者的相关函数调用代码
- gdb: value optimized out
- java集合类HashMap获取键和值
- 拷贝构造函数和赋值函数
- hdu1754