关于在64位linux下开发32位linux程序的一些问题

前几天在64位linux下开发跨平台的代码,包括32位和64位的版本都需要编译,在给g++加上-m32开关之后,g++报了一个错误:

gnu/stubs-32.h: No such file or directory compilation terminated. make: ***

在网上翻了一圈,情况就是64位linux缺省只安装了64位的头文件和Lib版本,需要增加32位的版本库,网上提到的安装方法一般是CentOs, Ubuntu之类的发行版,我用的是OpenSuse,最后在老外的网页上找到了一个比较全面的各个版本的安装说明:

You need 32bit embedded GNU C Library. This incldes development Libraries, header files, contains the symlinks, headers, and object files needed to compile and link programs which use the standard C library.

Fix for Debian Linux

Type the following command:
$ sudo apt-get install libc6-dev

Fix for Ubuntu Linux

Type the following command:
$ sudo apt-get install libc6-dev-i386

Fix for OpenSUSE / Novell Suse Linux (SLES)

Type the following command:
# zypper in glibc-devel-32bit

Fix for RHEL / Fedora / CentOS / Scientific Linux

Type the following command:
# yum install glibc-devel.i686

 

安装了头文件,还要注意安装库文件,方法同上,包括以下库:

gcc-32bit gcc7-32bit libstdc++6-gcc7-32bit libstdc++6-gcc7-locale libstdc++6-locale

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章