前幾天在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