Forum

> > Off Topic > Building GCC from source keeps falling.
ForenübersichtOff Topic-ÜbersichtEinloggen, um zu antworten

Englisch Building GCC from source keeps falling.

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Building GCC from source keeps falling.

MikuAuahDark
User Off Offline

Zitieren
So, first of all, I'm sorry if I really miss the basic things in building GCC.

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 hat geschrieben
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’

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?

alt Re: Building GCC from source keeps falling.

MikuAuahDark
User Off Offline

Zitieren
Sorry if I'm not clear.

Simply, I want to create Linux executable from Windows. Because I don't have the compiler (Google also doesn't give good result), I want to build GCC compiler with MinGW32 cross-compiler(runs in Linux but creates Windows executable) targetting i686-linux-gnu (so that the compiler runs on Windows machine and creates code for Linux machine).

Basically, I want to build GCC from computer A which does run in computer B and generate code for computer A where A is Linux and B is Windows. More simple again: Opposite of MinGW32 cross-compiler in Linux.

To be more specific, I want to compile my project for Windows and Linux platform. Windows is my main development operating system and starting Linux Virtual Machine to compile the Linux executable of my project is overkill. That's why I need Windows > Linux cross-compiler.

EDIT: Demonstration:
> i586-mingw32msvc-gcc runs under Linux but generates code for Windows.
> Building GCC with i586-mingw32msvc-gcc compiler instead of the usual compiler (cross-compiling) targetting i686-linux-gnu.
> i586-mingw32msvc-gcc outputs i686-linux-gnu-gcc.exe and it's friends that will run under Windows
> Then, I compiled program using i686-linux-gnu-gcc.exe in Windows, copy the resulting executable and run it under Linux.
1× editiert, zuletzt 14.03.16 16:03:17

alt Re: Building GCC from source keeps falling.

GeoB99
Moderator Off Offline

Zitieren
user MikuAuahDark hat geschrieben
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.

This issue could be caused in many factors, especially two ones. Firstly, whether the GCC is installed incorrectly or it's missing libc6-dev library. In order to download and set up in the system type this command:
1
sudo apt-get install libc6-dev
That's only a guess though. That might fix the problem somehow otherwise the highest change of getting this error is because of non-properly installation of GCC.

alt Re: Building GCC from source keeps falling.

oxytamine
User Off Offline

Zitieren
user GeoB99 hat geschrieben
Firstly, whether the GCC is installed incorrectly or it's missing libc6-dev library. In order to download and set up in the system type this command:
1
sudo apt-get install libc6-dev

Running "apt-get install libc6-dev" on Windows would definitely help.

@user MikuAuahDark:
What you are trying to achieve is by far one of the most retarded things I have ever heard. You're hitting such autism level that shouldn't even be possible. Just install any Linux distribution (together with Windows) or build your executables on virtual machine.

Admin/Mod Kommentar

I do get your point however "you're hitting such autism level" is kinda exagerated. /ZxC Regeln §3.1 - Keine Beiträge, die gezielt beleidigen/provozieren (Flame)

alt Re: Building GCC from source keeps falling.

MikuAuahDark
User Off Offline

Zitieren
@user GeoB99: Looks like that I forgot to specify --disable-multilib in my configuration and that causes the error.

user oxytamine hat geschrieben
You're hitting such autism level that shouldn't even be possible

Then please explain to me why there's Android NDK compiler toolchain that can run under Windows (currently I have it).

Anyway, here is the exact error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
make[4]: Entering directory `/home/mikuauahdark/gcc-4.8.5/gcc-4.8.5/mytest/i686-linux-gnu/64/libgcc'
# If this is the top-level multilib, build all the other
# multilibs.
cc   -g -O2 -m64 -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../../.././gcc -I../../../../libgcc -I../../../../libgcc/. -I../../../../libgcc/../gcc -I../../../../libgcc/../include -I../../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c ../../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from /usr/include/stdio.h:27:0,
                 from ../../../../libgcc/../gcc/tsystem.h:87,
                 from ../../../../libgcc/libgcc2.c:27:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
 #  include <sys/cdefs.h>
                         ^
compilation terminated.
make[4]: *** [_muldi3.o] Error 1
make[4]: Leaving directory `/home/mikuauahdark/gcc-4.8.5/gcc-4.8.5/mytest/i686-linux-gnu/64/libgcc'
make[3]: *** [multi-do] Error 1
make[3]: Leaving directory `/home/mikuauahdark/gcc-4.8.5/gcc-4.8.5/mytest/i686-linux-gnu/libgcc'
make[2]: *** [all-multi] Error 2
make[2]: Leaving directory `/home/mikuauahdark/gcc-4.8.5/gcc-4.8.5/mytest/i686-linux-gnu/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/mikuauahdark/gcc-4.8.5/gcc-4.8.5/mytest'
make: *** [all] Error 2
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antwortenOff Topic-ÜbersichtForenübersicht