GCC should support or run with multilib to eliminate this error.
ERROR: Fatal error wordsize.h no such file or directory along with other warnings when building Linux kernel
Missing `bits/wordsize.h` while compiling
c - fatal error: 'bits/types.h' file not found - Stack Overflow
c - "fatal error: bits/libc-header-start.h: No such file or directory" while compiling HTK - Stack Overflow
The picture is in the comments section. Can someone please help? Im stuck on this error for about 2hrs ( + 1hr bc of the post time)
The -m32 is telling gcc to compile for a 32-bit platform. On a 64-bit platform, gcc normally only comes with 64-bit libraries. You have two options:
Install 32-bit headers and libraries. Here's how you'd do this on Ubuntu.
Run this command:
sudo apt-get install gcc-multilibCompile for 64-bit instead. Modify this line in the file named
configure:CFLAGS="-m32 -ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH=\"$host_cpu\"' $CFLAGS"Delete
-m32, giving you:CFLAGS="-ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH=\"$host_cpu\"' $CFLAGS"Run
./configure, thenmake clean, thenmakeHowever, I would recommend against this approach. The library authors went out of their way to make this build for 32 bits on a 64 bit system, and I can't guarantee that it will work correctly if you do this. (It does compile, though.)
Below is one way to debug and fix this issue. Since most linux installations differ in one way or another, YMMV.
- Find which package installed
libc-header-start.h.
$ dpkg -S libc-header-start.h
libc6-dev:amd64: /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
On a working system, /usr/include/bits is a symlink to /usr/include/x86_64-linux-gnu/bits. Running dpkg search gives us:
$ dpkg -S /usr/include/bits
libc6-dev-i386: /usr/include/bits
Installing libc6-dev-i386 creates the symlink and the error is addressed.
However, subsequently I ran into a linker error with the linker not being able to find libgcc (-lgcc). Apparently Linux default linker needs libgcc in most cases. Further debugging the issue with linker verbosity enabled lead me to missing lib32gcc-10-dev package.
In short, unless a very controlled build environment is desired, just install gcc-multilib package when using -m32 (needed for gcc or clang). For C++, g++-multilib is also required.
Each supported architecture under Linux defines BITS_PER_LONG in <asm/types.h> to the length of the C long type, which is the system word size.
From http://www.makelinux.net/books/lkd2/ch19lev1sec2
Word Size in any architecture is equivalent to of size of long datatype.
So use
#define __WORDSIZE sizeof(long)
You can alternatively use size of pointer too.