I want to build GCC cross-compiler which compiles Linux executable from Windows. Yes, Compiler running in Windows creating Linux executable, you read it correctly. As there's not much in Google (mostly shows creating Windows executable from Linux), I want to do it myself. Unfortunately, I'm getting errors.
Here's my configure script. I use Ubuntu in this case.
../configure --host=i586-mingw32msvc --target=i686-linux-gnu --enable-languages=c,c++ --enable-shared --enable-linker-build-id --without-included-gettext --enable-threads=posix --enable-sjlj-exceptions --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-plugin --without-system-zlib --with-arch-directory=i386 --disable-multiarch --with-tune=generic
The first error that came is zlib.h not found, even I specify --without-system-zlib above. I fixed it by copying zlib-related file to mingw include lib folder.
Then the next error comes, sys/cdefs.h: no such file or directory. I still don't know how to solve this one. Perhaps something is wrong in my configuration.
i586-mingw32msvc-gcc -v says it's version 4.2.1 so maybe it's pretty old to compile GCC 4.8.5 and causes problems.
I also read the GCC prerequisites and I'm confused in this.
Prerequisites for GCC has written
C standard library and headers
In order to build GCC, the C standard library and headers must be present for all target variants for which target libraries will be built (and not only the variant of the host C++ compiler).
This affects the popular ‘x86_64-unknown-linux-gnu’ platform (among other multilib targets), for which 64-bit (‘x86_64’) and 32-bit (‘i386’) libc headers are usually packaged separately. If you do a build of a native compiler on ‘x86_64-unknown-linux-gnu’, make sure you either have the 32-bit libc developer package properly installed (the exact name of the package depends on your distro) or you must build GCC as a 64-bit only compiler by configuring with the option --disable-multilib. Otherwise, you may encounter an error such as ‘fatal error: gnu/stubs-32.h: No such file’
In order to build GCC, the C standard library and headers must be present for all target variants for which target libraries will be built (and not only the variant of the host C++ compiler).
This affects the popular ‘x86_64-unknown-linux-gnu’ platform (among other multilib targets), for which 64-bit (‘x86_64’) and 32-bit (‘i386’) libc headers are usually packaged separately. If you do a build of a native compiler on ‘x86_64-unknown-linux-gnu’, make sure you either have the 32-bit libc developer package properly installed (the exact name of the package depends on your distro) or you must build GCC as a 64-bit only compiler by configuring with the option --disable-multilib. Otherwise, you may encounter an error such as ‘fatal error: gnu/stubs-32.h: No such file’
Where I should put the C standard library headers?
PS: Before I tried to compile in Ubuntu, I tried to build it with MinGW in Windows, but I'm getting stdc-predef.h not found.
Any suggestions?