This is a discussion on cpp and header files within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I have gcc 3.3.4 and kernel header files installed on standard path from slackware 10 setup script (/usr/include/linux) but ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have gcc 3.3.4 and kernel header files installed on standard path from slackware 10 setup script (/usr/include/linux) but cpp does not find the headers. For example if I run $ cpp test.c with test.c containing: #include <types.h> the preprocessor returns: "types.h: No such file or directory". Am I in trouble with standard system directories ? $ cpp -I /usr/include/linux test.c works fine; Is there no compatibilty between kernel-headers-2.4.26 and gcc-3.3.4-i486.1 ? How can I arrange things to work ? Thanks Nello Sola |
| |||
| On 7 Aug 2004 07:45:20 -0700, Nello Sola <nello.sola@libero.it> wrote: > I have gcc 3.3.4 and kernel header files installed on standard path > from slackware 10 setup script (/usr/include/linux) but cpp does not > find the headers. For example if I run $ cpp test.c with test.c > containing: #include <types.h> the preprocessor returns: > "types.h: No such file or directory". Am I in trouble with standard > system directories ? I don't know what cpp's normal behaviour is, but it seems you'd have to write #include <linux/types.h> for the header to be found. This seems to be because /usr/include is in cpp's default header search path, and not /usr/include/linux specifically. (See 'cpp -v') > How can I arrange things to work ? You can add /usr/include/linux to the CPATH variable, for that directory to be in the default path. The ENVIRONMENT section of man cpp has more details. -- Mark Hill <mrhill@gmail.com> Email: echo zbp.yvnzt.yyvuez | rot13 | rev | sed s/\\./@/ |
| |||
| Mark Hill <mrhill@gmail.com> wrote: >On 7 Aug 2004 07:45:20 -0700, >Nello Sola <nello.sola@libero.it> wrote: >> I have gcc 3.3.4 and kernel header files installed on standard path >> from slackware 10 setup script (/usr/include/linux) but cpp does not >> find the headers. For example if I run $ cpp test.c with test.c >> containing: #include <types.h> the preprocessor returns: >> "types.h: No such file or directory". Am I in trouble with standard >> system directories ? > >I don't know what cpp's normal behaviour is, but it seems you'd have to >write #include <linux/types.h> for the header to be found. This seems >to be because /usr/include is in cpp's default header search path, and >not /usr/include/linux specifically. (See 'cpp -v') He almost certainly does *not* want to do that. Rather, #include <sys/types.h> is probably what he does want. The discussion of the default search path for include files is correct. >> How can I arrange things to work ? > >You can add /usr/include/linux to the CPATH variable, for that directory >to be in the default path. The ENVIRONMENT section of man cpp has more >details. That would probably be a very poor idea; not the least of reasons being it includes the wrong header, but also because the right way is specific to the source file, not to the environment in which it is compiled. The correct way is also demonstrated in virtually every section 3 man page that shows various header files which need to be included to provide the compiler a proper interface for the given functions and libraries. Examples are man pages for getpw(3) and opendir(3), SYNOPSIS ... #include <sys/types.h> -- FloydL. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
| |||
| On Sat, 07 Aug 2004 12:44:42 -0800, Floyd L. Davidson <floyd@barrow.com> wrote: > > He almost certainly does *not* want to do that. Rather, > > #include <sys/types.h> > > is probably what he does want. The discussion of the default > search path for include files is correct. I see. Thanks for the info. -- Mark Hill <mrhill@gmail.com> Email: echo zbp.yvnzt.yyvuez | rot13 | rev | sed s/\\./@/ |
| |||
| floyd@barrow.com (Floyd L. Davidson) wrote in message > > He almost certainly does *not* want to do that. Rather, > > #include <sys/types.h> > > is probably what he does want. The discussion of the default > search path for include files is correct. > The correct way is also demonstrated in virtually every section > 3 man page that shows various header files which need to be > included to provide the compiler a proper interface for the > given functions and libraries. Examples are man pages for > getpw(3) and opendir(3), > > SYNOPSIS > ... > #include <sys/types.h> I was thinking so, but in the tree /usr/include/linux/ the directory ../sys does not exist; I have: /usr/include/linux/types.h My troubles originate when I start to compile qmail with: make setup check The compiler (the preprocessor I suppose) returns: qmail-local.c:1:23: sys/types.h: No such file or directory The line 1 in the source code qmail-local.c is properly: #include <sys/types.h> but the preprocessor does not find it. Besides, when I compiled qmail with compiler installed by the Slackware 8.1, I had non this problems. Nello |
| |||
| nello.sola@libero.it (Nello Sola) wrote: >floyd@barrow.com (Floyd L. Davidson) wrote in message >> >> He almost certainly does *not* want to do that. Rather, >> >> #include <sys/types.h> >> >> is probably what he does want. The discussion of the default >> search path for include files is correct. > >> The correct way is also demonstrated in virtually every section >> 3 man page that shows various header files which need to be >> included to provide the compiler a proper interface for the >> given functions and libraries. Examples are man pages for >> getpw(3) and opendir(3), >> >> SYNOPSIS >> ... >> #include <sys/types.h> > >I was thinking so, but in the tree /usr/include/linux/ the directory >./sys does not exist; I have: > > /usr/include/linux/types.h Do you have a file /usr/include/sys/types.h though???? If not, that is the problem. If you do have that file then something the Makefile is doing isn't working right. >My troubles originate when I start to compile qmail with: > > make setup check > >The compiler (the preprocessor I suppose) returns: > > qmail-local.c:1:23: sys/types.h: No such file or directory > >The line 1 in the source code qmail-local.c is properly: > > #include <sys/types.h> > >but the preprocessor does not find it. Hmmm... >Besides, when I compiled qmail with compiler installed by the >Slackware 8.1, I had non this problems. I'm using a locally upgraded Slackware 8.0, so I can't really test this then. Maybe somebody who has the same distribution as you has also compiled qmail. Another interesting bit of information would be if you made a file, perhaps called foo.c, that has this in it: #include <sys/types.h> int main(void){return 0;} And compile it with this command, gcc -v foo.c And then cut and paste the resulting output here. That will show the default paths that the preprocessor is using. -- FloydL. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
| |||
| Floyd L. Davidson wrote: > nello.sola@libero.it (Nello Sola) wrote: >>> SYNOPSIS >>> ... >>> #include <sys/types.h> >> >>I was thinking so, but in the tree /usr/include/linux/ the directory >>./sys does not exist; I have: >> >> /usr/include/linux/types.h > > Do you have a file /usr/include/sys/types.h though???? No, he just said, he doesn't even have a /usr/include/sys directory. > > If not, that is the problem. If you do have that file then > something the Makefile is doing isn't working right. > >>My troubles originate when I start to compile qmail with: >> >> make setup check >> >>The compiler (the preprocessor I suppose) returns: >> >> qmail-local.c:1:23: sys/types.h: No such file or directory >> That's because there isn't any >>The line 1 in the source code qmail-local.c is properly: >> >> #include <sys/types.h> You're trying to include that file that doesn't exist. But you've said you have a /usr/include/linux/types.h . This kind of scares me. I just looked, and I have that file too. I've always seen it as sys/types.h, but I've been out of the loop for a number of years; maybe they changed the "standard." So, to include that file, your source line would be #include <types.h> assuming that the compiler is looking in /usr/include for its include files. I don't know why there's a difference, unless your source is meant to compile against a different version of the libraries. And I don't know which one is "right." Sorry. Rich |
| |||
| Rich Grise <null@example.net> wrote: >Floyd L. Davidson wrote: > >> nello.sola@libero.it (Nello Sola) wrote: >>>> SYNOPSIS >>>> ... >>>> #include <sys/types.h> >>> >>>I was thinking so, but in the tree /usr/include/linux/ the directory >>>./sys does not exist; I have: >>> >>> /usr/include/linux/types.h >> >> Do you have a file /usr/include/sys/types.h though???? > >No, he just said, he doesn't even have a /usr/include/sys directory. He might well have meant to say that, but that is *not* what he said. Which is why I asked for clarification. >> If not, that is the problem. If you do have that file then >> something the Makefile is doing isn't working right. The above statement is significant, and should not be ignored. >>>My troubles originate when I start to compile qmail with: >>> >>> make setup check >>> >>>The compiler (the preprocessor I suppose) returns: >>> >>> qmail-local.c:1:23: sys/types.h: No such file or directory >>> >That's because there isn't any > >>>The line 1 in the source code qmail-local.c is properly: >>> >>> #include <sys/types.h> > >You're trying to include that file that doesn't exist. But you've >said you have a /usr/include/linux/types.h . > >This kind of scares me. I just looked, and I have that file too. >I've always seen it as sys/types.h, but I've been out of the loop >for a number of years; maybe they changed the "standard." What are you babbling about? >So, to include that file, your source line would be >#include <types.h> > >assuming that the compiler is looking in /usr/include for its include >files. > >I don't know why there's a difference, unless your source is meant to >compile against a different version of the libraries. And I don't >know which one is "right." Eh? This has nothing to do with libraries. The standard file is /usr/include/sys/types.h, there are also at least three other "types.h" files (there are more, but these are enough to scare you sufficiently): /usr/include/asm/types.h for modules, and the kernel /usr/include/bits/types.h for applications /usr/include/linux/types.h for the kernel The one he is looking for is /usr/include/bits/types.h, which is the Linux specific file that is included from the Unix standard file /usr/include/sys/types.h. The other two are in directories that are symlinked to the kernel source directory used to compile the standard C library (*not* necessarily the source directory for the currently used kernel). If the OP is missing either of /usr/include/sys/types.h or /usr/include/bits/types.h, then he has an incompletely installed development system. -- FloydL. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
| |||
| Floyd L. Davidson wrote: .... > The standard file is /usr/include/sys/types.h, there are also at > least three other "types.h" files (there are more, but these are > enough to scare you sufficiently): > > /usr/include/asm/types.h for modules, and the kernel > /usr/include/bits/types.h for applications > /usr/include/linux/types.h for the kernel > > The one he is looking for is /usr/include/bits/types.h, which > is the Linux specific file that is included from the Unix standard > file /usr/include/sys/types.h. > > The other two are in directories that are symlinked to the kernel > source directory used to compile the standard C library (*not* > necessarily the source directory for the currently used kernel). > > If the OP is missing either of /usr/include/sys/types.h or > /usr/include/bits/types.h, then he has an incompletely installed > development system. > Thanks for clearing that up. Cheers! Rich |
| ||||
| Rich Grise <null@example.net> wrote: >Floyd L. Davidson wrote: >... >> The standard file is /usr/include/sys/types.h, there are also at >> least three other "types.h" files (there are more, but these are >> enough to scare you sufficiently): >> >> /usr/include/asm/types.h for modules, and the kernel >> /usr/include/bits/types.h for applications >> /usr/include/linux/types.h for the kernel >> >> The one he is looking for is /usr/include/bits/types.h, which >> is the Linux specific file that is included from the Unix standard >> file /usr/include/sys/types.h. >> >> The other two are in directories that are symlinked to the kernel >> source directory used to compile the standard C library (*not* >> necessarily the source directory for the currently used kernel). >> >> If the OP is missing either of /usr/include/sys/types.h or >> /usr/include/bits/types.h, then he has an incompletely installed >> development system. >> >Thanks for clearing that up. > >Cheers! >Rich Damn newbies. ;-) -- FloydL. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |