You're missing the 32 bit libc dev package:
On Ubuntu it's called libc6-dev-i386 - do sudo apt-get install libc6-dev-i386
. See below for extra instructions for Ubuntu 12.04.
On Red Hat distros, the package name is glibc-devel.i686
(Thanks to David Gardner's comment).
On CentOS 5.8, the package name is glibc-devel.i386
(Thanks to JimKleck's comment).
On CentOS 6 / 7, the package name is glibc-devel.i686
.
On SLES it's called glibc-devel-32bit - do zypper in glibc-devel-32bit
.
On Gentoo it's called sys-libs/glibc
- do emerge -1a sys-libs/gcc
[source] (Note : One may use equery
to confirm this is correct; do equery belongs belongs /usr/include/gnu/stubs-32.h
)
On ArchLinux, the package name is lib32-glibc
- do pacman -S lib32-glibc
.
Are you using Ubuntu 12.04? There is a known problem that puts the files in a non standard location. You'll also need to do:
export LIBRARY_PATH=/usr/lib/$(gcc -print-multiarch)
export C_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)
export CPLUS_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)
somewhere before you build (say in your .bashrc).
If you are also compiling C++ code, you will also need the 32 bit stdc++ library. If you see this warning:
.... /usr/bin/ld: cannot find -lstdc++ ....
On Ubuntu you will need to do sudo apt-get install g++-multilib
On CentOS 5 you will need to do yum install libstdc++-devel.i386
On CentOS 6 you will need to do yum install libstdc++-devel.i686
Please feel free to edit in the packages for other systems.
From the GNU UPC website:
Compiler build fails with fatal error: gnu/stubs-32.h: No such file or directory
This error message shows up on the 64 bit systems where GCC/UPC multilib feature is enabled, and it indicates that 32 bit version of libc is not installed. There are two ways to correct this problem:
- Install 32 bit version of glibc (e.g. glibc-devel.i686 on Fedora, CentOS, ..)
- Disable 'multilib' build by supplying "--disable-multilib" switch on the compiler configuration command
Try doing a sudo apt-get install libc6-dev
.
apt-file
tells me that the file in question belongs to that package.
This is now in the GCC wiki FAQ, see http://gcc.gnu.org/wiki/FAQ#gnu_stubs-32.h
Hmm well I am on ubuntu 12.04 and I got this same error when trying to compile gcc 4.7.2
I tried installing the libc6-dev-i386
package and got the following:
Package libc6-dev-i386 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libc6-dev-i386' has no installation candidate
I also set the correct environment variables in bash:
export LIBRARY_PATH=/usr/lib/$(gcc -print-multiarch)
export C_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)
export CPLUS_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)
however, I was still getting the error then I simply copied stubs-32.h
over to where gcc was expecting to find it after doing a quick diff:
vic@ubuntu:/usr/include/i386-linux-gnu/gnu$ diff ../../gnu ./
Only in ./: stubs-32.h
Only in ../../gnu: stubs-64.h
vic@ubuntu:/usr/include/i386-linux-gnu/gnu$ sudo cp stubs-32.h ../../gnu/
[sudo] password for vic:
vic@ubuntu:/usr/include/i386-linux-gnu/gnu$ diff ../../gnu ./
Only in ../../gnu: stubs-64.h
vic@ubuntu:/usr/include/i386-linux-gnu/gnu$
It's compiling now, let's see if it complains more ...
I was getting following error on a fedora 18 box:
1. /usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory compilation terminated.
I Installed glibc.i686 and glibc-devel.i686, then compilation failed with following error:
2. /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/libgcc_s.so when searching for -lgcc_s /usr/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status
Solution:
I installed (yum install) glibc.i686 glibc-devel.i386 and libgcc.i686 to get rid of the compilation issue.
Now compilation for 32 bit (-m32) works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With