Discussion:
stdio.h: File not found?!?
Martin Krischik
2006-04-05 17:57:08 UTC
Permalink
Hello

I am trying a cross compile (--build=x86_64-suse-linux
--host=x86_64-suse-linux --target=mingw32) and I get the following strange
error message:

------------
make[3]: Entering directory
`/work/rpm/BUILD/gnat-gcc-mingw/x86_64-suse-linux/gcc'
/work/rpm/BUILD/gnat-gcc-mingw/x86_64-suse-linux/./gcc/xgcc
-B/work/rpm/BUILD/gnat-gcc-mingw/x86_64-suse-linux/./gcc/
-B/opt/gnat/gcc-mingw/mingw32/bin/ -B/opt/gnat/gcc-mingw/mingw32/lib/
-isystem /opt/gnat/gcc-mingw/mingw32/include
-isystem /opt/gnat/gcc-mingw/mingw32/sys-include -O2
-I../../gcc-4.1.0/gcc/../winsup/w32api/include -O2 -g -O2 -DIN_GCC
-DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition -isystem ./include -g
-DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I.
-I. -I../../gcc-4.1.0/gcc -I../../gcc-4.1.0/gcc/.
-I../../gcc-4.1.0/gcc/../include -I../../gcc-4.1.0/gcc/../libcpp/include
-DL_muldi3 -c ../../gcc-4.1.0/gcc/libgcc2.c -o libgcc/./_muldi3.o
In file included from ./tm.h:10,
from ../../gcc-4.1.0/gcc/libgcc2.c:35:
../../gcc-4.1.0/gcc/config/i386/cygming.h:52:19: error: stdio.h: Datei oder
Verzeichnis nicht gefunden
In file included from ./tm.h:10,
from ../../gcc-4.1.0/gcc/libgcc2.c:35:
../../gcc-4.1.0/gcc/config/i386/cygming.h:333: error: expected ‘)’ before ‘*’
token
make[3]: *** [libgcc/./_muldi3.o] Fehler 1
------------

In English the error message reads: file not found.

And that is strange in the sense that according to ISO 9899:1999(7.19) stdio.h
a part of the of a propper C compiler and therfore the compiler sources
should come with suitable stdio.h. So where is it?

Of corse: since it is a --build=x86_64-suse-linux --host=x86_64-suse-linux
compile using /usr/include/stdio.h should be ok as well. Or did I miss read
the cross compile instructions completely?

Any ideas?

Martin

PS: Just in case you wonder: MinGW's make.exe is completely broken and can't
even do a propper "make --help" let allone compile the current gcc tree.
--
Martin Krischik
mailto://***@users.sourceforge.net
Brian Dessent
2006-04-05 23:45:10 UTC
Permalink
Post by Martin Krischik
And that is strange in the sense that according to ISO 9899:1999(7.19) stdio.h
a part of the of a propper C compiler and therfore the compiler sources
should come with suitable stdio.h. So where is it?
That's not how it works. GCC does not provide a C library, it is just a
compiler. The two are completely separate. If you are building a mingw
cross compiler I advise that you look on the mingw wiki for example
scripts that take care of this. If you want to do it by hand you'll
need to download and install the headers and import libraries (packages
mingw-runtime and w32api) first before you build the compiler.
Post by Martin Krischik
Of corse: since it is a --build=x86_64-suse-linux --host=x86_64-suse-linux
compile using /usr/include/stdio.h should be ok as well. Or did I miss read
the cross compile instructions completely?
That stdio.h is for native compilation, it will do you no good when
doing cross compilation to a completely separate target (like mingw.)

Brian
Martin Krischik
2006-04-06 08:26:54 UTC
Permalink
Post by Brian Dessent
Post by Martin Krischik
And that is strange in the sense that according to ISO
9899:1999(7.19) stdio.h
a part of the of a propper C compiler and therfore the compiler sources
should come with suitable stdio.h. So where is it?
That's not how it works. GCC does not provide a C library, it is just a
compiler. The two are completely separate. If you are building a mingw
cross compiler I advise that you look on the mingw wiki for example
scripts that take care of this. If you want to do it by hand you'll
need to download and install the headers and import libraries (packages
mingw-runtime and w32api) first before you build the compiler.
I did not expect to need a mingw-runtime before the 2nd step (creating
a --build=x86_64-suse-linux --host=mingw --target=mingw compiler) -
see below.
Post by Brian Dessent
Post by Martin Krischik
Of corse: since it is a --build=x86_64-suse-linux --host=x86_64-suse-linux
compile using /usr/include/stdio.h should be ok as well. Or did I miss read
the cross compile instructions completely?
That stdio.h is for native compilation, it will do you no good when
doing cross compilation to a completely separate target (like mingw.)
You see me confused. I thought that a "--build=x86_64-suse-linux
--host=x86_64-suse-linux" compiler is to run under Linux - what does
is need a MinGW runtime so soon? - I am only trying to create the
cross-compiler itself - I am not yet trying to create any MinGW
binaries with it.

Martin
Brian Dessent
2006-04-06 08:37:14 UTC
Permalink
Post by Martin Krischik
You see me confused. I thought that a "--build=x86_64-suse-linux
--host=x86_64-suse-linux" compiler is to run under Linux - what does
is need a MinGW runtime so soon? - I am only trying to create the
cross-compiler itself - I am not yet trying to create any MinGW
binaries with it.
The error that you got is in the building of libgcc. By that point the
compiler has already bootstrapped itself, and now it's cross compiling
the target libraries, i.e. code that will be run on the target. So yes,
at this point you need the target headers that describe the C runtime of
the target, not the host.

Brian
Brian Dessent
2006-04-06 09:01:11 UTC
Permalink
By that point the compiler has already bootstrapped itself,
Er, it hasn't bootstrapped itself since you're doing a cross compile
(and bootstrap is only for native), but what I mean is that it has been
built.

Brian
Martin Krischik
2006-04-06 17:44:16 UTC
Permalink
Post by Brian Dessent
Post by Martin Krischik
You see me confused. I thought that a "--build=x86_64-suse-linux
--host=x86_64-suse-linux" compiler is to run under Linux - what does
is need a MinGW runtime so soon? - I am only trying to create the
cross-compiler itself - I am not yet trying to create any MinGW
binaries with it.
The error that you got is in the building of libgcc. By that point the
compiler has already bootstrapped itself, and now it's cross compiling
the target libraries, i.e. code that will be run on the target. So yes,
at this point you need the target headers that describe the C runtime of
the target, not the host.
Thanks for the explanation. The compile is now running nicely.

Martin
--
Martin Krischik
mailto://***@users.sourceforge.net
Kai Ruottu
2006-04-06 13:18:18 UTC
Permalink
I did not expect to need a mingw-runtime before the 2nd step (creating a
--build=x86_64-suse-linux --host=mingw --target=mingw compiler)
In order to produce MinGW apps on Linux, you need binutils, GCC and
target headers plus libraries... A GCC which can only produce 'i386-pe'
objects (the Windoze object format) with 'as' from binutils, isn't very
useful
for anything...

Producing GCC requires a "complete C compiler". The "ISO99 C compiler"
the "Prerequisites" in the "Installing GCC" talks about is something
very weird
gibberish for most people. Because GCC oneself cannot produce GCC, then
GCC isn't a "ISO99 C compiler" or how?
Post by Martin Krischik
Of corse: since it is a --build=x86_64-suse-linux
--host=x86_64-suse-linux
compile using /usr/include/stdio.h should be ok as well. Or did I miss read
the cross compile instructions completely?
Probably... The ones in the gcc-2.95.3 manual are still true! When
the cross
compile instructions clearly tell that the target C library MUST be
present, its
headers required for fixing them for GCC first, then used when producing the
target libraries (libgcc, libiberty, libstdc++,...), and the library
binaries required
for checking what the target C library has or has not, you should
believe ! And
when the author of the manual is called Richard M.Stallman, what reasons you
have to not believe? Although the current version is 4.x, these basic
things
haven't changed at all, still there is that 'fixincludes' phase, target
headers used
when producing 'libgcc.a' and target libraries used when producing
'libgcc_s.so'
(for Unix-like targets) and when doing link tests during the libiberty
and libstdc++
configures...
You see me confused. I thought that a "--build=x86_64-suse-linux
--host=x86_64-suse-linux" compiler is to run under Linux - what does
is need
a MinGW runtime so soon? - I am only trying to create the
cross-compiler itself
- I am not yet trying to create any MinGW binaries with it.
Even "compiling" that "Hello World" has the "#include <stdio.h>", so
most newbies
know these (target) headers being obligatory. "Linking" it then requires
the startups
and those target libraries ('libc' usually but with MinGW that is
'libmsvcrt'). So what
you think a compiler being differs horribly about what a newbie thinks
it being and
what one can do with a "compiler"... Usually this requirement is "It can
compile the
Hello World", and here that "compile" means "producing the executable
"hello.exe"
from the source "hello.c" !

The expectation for "producing a crosscompiler for MinGW" is that the
builder
wants to be capable to (at least) produce that "Hello World" for MinGW
after the
compiler is ready.
Kai Ruottu
2006-04-06 14:02:46 UTC
Permalink
Post by Martin Krischik
I did not expect to need a mingw-runtime before the 2nd step
(creating a
Post by Martin Krischik
--build=x86_64-suse-linux --host=mingw --target=mingw compiler)
Producing GCC requires a "complete C compiler". The "ISO99 C compiler"
the "Prerequisites" in the "Installing GCC" talks about is something
very weird
gibberish for most people. Because GCC oneself cannot produce GCC, then
GCC isn't a "ISO99 C compiler" or how?
Why I took this here, is that the '--host=mingw --target=mingw'
requires a complete
C compiler for the '$host', here 'mingw'. Producing 'xgcc.exe',
'cc1.exe', 'collect2.exe'
(maybe this doesn't succeed even now!) for MinGW host of course requires
that the
"C compiler can create executables" (a funny joke the GCC build told to
the builder
earlier, that "C compiler cannot create executables" - a fact when one
talks about GCC,
but now this error message has bee changed to "Linking is not allowed after
GCC_NO_EXECUTABLES" or something....)

So the target C library is required already when producing a
cross-GCC. Adding it
later is not the rule... Also producing a native GCC requires the
target C library being
in '/lib', '/usr/lib', '/usr/include' etc. but people usually don't see
anything weird in that...
That the target C library is required when producing a cross GCC then
seems to be
something totally weird for many GCC builders. However just the same
operations,
fixincludes, compiling libgcc, libiberty, libstdc++, doing link tests
with the target C
library, will happen in both cases.... Maybe one's political attitude
says that this is
not right and it should be otherwise, but this is the reality just now.
All nagging should
be sent to the GCC developers in order to get these operations removed :-)
Martin Krischik
2006-04-06 18:31:10 UTC
Permalink
Post by Kai Ruottu
Producing GCC requires a "complete C compiler". The "ISO99 C compiler"
the "Prerequisites" in the "Installing GCC" talks about is something
very weird
gibberish for most people. Because GCC oneself cannot produce GCC, then
GCC isn't a "ISO99 C compiler" or how?
Even "compiling" that "Hello World" has the "#include <stdio.h>", so
most newbies
know these (target) headers being obligatory. "Linking" it then requires
the startups
and those target libraries ('libc' usually but with MinGW that is
'libmsvcrt'). So what
you think a compiler being differs horribly about what a newbie thinks
it being and
what one can do with a "compiler"... Usually this requirement is "It can
compile the
Hello World", and here that "compile" means "producing the executable
"hello.exe"
from the source "hello.c" !
Actually I have spend the $ 18 on an copy of the ISO/IEC 9899/1999 and read
id. The standart consists of:

A) A programming and runtime environment (Chapter 5)
B) A programming language (Chapter 6)
C) A predefined library (Chapter 7)

And <stdio.h> is part of the predefined language library (Chapter 7.19, Page
261 to 303). A fully compliant language environment must provide them - not
the operating system.

Because the standart is far broader then you can obviously imagine: The
standart covers covers operating systems not written in C.

That GCC expects the operating system to provide 240 pages of its language
definition is a bit cheeky. Especially since the standart consists only of
540 pages.

So to answer your initial question: GCC on its own is indeed not a C99
compliant language environment - only in combination with glibc it becomes
C99 compliant.

On the other hand: if you set "--enable-languages=c,ada" you get the full Ada
compiler and the predefined library to go with it as defined in the ISO/IEC
8652:1995. No need to install some libada first.

Martin
--
Martin Krischik
mailto://***@users.sourceforge.net
Continue reading on narkive:
Loading...