Fedora Linux Support Community & Resources Center
  #1  
Old 18th December 2006, 01:24 PM
beny Offline
Registered User
 
Join Date: Apr 2005
Posts: 123
C header files

What is the location of the directory of C header files that match your running
kernel?

Is anybody who can answer this question? I am on FC6 system.
Reply With Quote
  #2  
Old 18th December 2006, 01:32 PM
keeler1 Offline
Registered User
 
Join Date: Oct 2006
Posts: 201
Not exactly sure but i believe that it is /lib/libc.so.6. I wrote a program once which seg faulted in the function fclose. When i used the debugger that is where it said that it seg faulted. One thing that would lead me to believe that is not it is the fact that it is not a directory. It is a file. A very long file in unreadable object code. I am fairly certain this is where the object code for the standard library files are kept. Again, someone else who knows for sure probably ought to tell you.

While on the topic of c header files. Would it be possible to put your own header files into the standard library so that you could include them no matter which directory you are writing the code in?
Reply With Quote
  #3  
Old 18th December 2006, 01:52 PM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
Quote:
Originally Posted by keeler1
While on the topic of c header files. Would it be possible to put your own header files into the standard library so that you could include them no matter which directory you are writing the code in?
Yes, you can override the standard C header path. But why would you do that ? The directory you are writing the code in (your default directory) is irrelevant.
Reply With Quote
  #4  
Old 18th December 2006, 02:30 PM
keeler1 Offline
Registered User
 
Join Date: Oct 2006
Posts: 201
Quote:
Originally Posted by giulix
Yes, you can override the standard C header path. But why would you do that ? The directory you are writing the code in (your default directory) is irrelevant.
I didnt want to overwrite the path, i just want to add more of my own header files to the directory gcc looks for stdio.h ctype.h and all of the other function libraries. I dont want to delete any i just want to add in more. If i added them to the /usr/src/kernels/ --- /include directory, would i then be able to #include the header files just as i would stdio.h and all the other c header files
Reply With Quote
  #5  
Old 18th December 2006, 01:43 PM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
First, find out which kernel release you're running
Code:
uname -r
Then, locate the corresponding directory under /usr/src/kernels
Code:
ls -l /usr/src/kernels
If you prefer, here's a shortcut
Code:
ls -l /usr/src/kernels/`uname -r`*/include
That is where your kernel headers are. The asterisk is needed to expand the directory name to include your architecture; include is the conventional place where the headers go.
Reply With Quote
  #6  
Old 18th December 2006, 03:27 PM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
No, you wouldn't. The canonical way is to include your headers by specifying their paths to gcc with the -I option. If you have a directory with your module sources, say ./somemodule in which you store C code and header files, the preferred way is to include the headers with the double quote syntax, i.e.
Code:
#include "someheader.h"
which will find it in the current (default) directory. Else, just compile the program with
Code:
gcc -I /path_to_include -o program program.c
where path_to_include is the directory which contains your header files.
Reply With Quote
  #7  
Old 18th December 2006, 03:44 PM
keeler1 Offline
Registered User
 
Join Date: Oct 2006
Posts: 201
So lets say i have a bunch of header files stored in one place but not all. Will gcc still look for some of the header files in the current directory or will it only look in the specified path? I may be testing out a program and do not want to permanently put the header files into that directory just yet because i havent finished editing them. So is there a way to tell gcc to look for header files in multiple paths.
Reply With Quote
  #8  
Old 18th December 2006, 03:58 PM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
gcc looks for standard header files, e.g. stdio.h and stdlib.h, by default in the /usr/include system directory. You can override this (but there's no need to) with the --sysroot option.
As far as your header files are concerned, you can store them anywhere you like, provided you tell gcc where to find them when you compile your program/modules.
Say you have a program, hello.c, in your home directory /home/keeler, and you have written a header file hello.h which you store in /home/keeler/include, plus you want to include another header, zorro.h, which is in /usr/src/kernels/2.6.18-1.2849.fc6-i686/include/linux.
To compile the program, you'll specify
Code:
cd $HOME
gcc -I ./include -I /usr/src/kernels/2.6.18-1.2849.fc6-i686/include/linux -o hello hello.c
Naturally, the program will also contain #includes of standard headers like stdio.h and stdlib.h, but you don't have to specify where to find those, provided the ones you want to include are the ones in /usr/include, as this is the standard path where the compiler will look for them.
Reply With Quote
  #9  
Old 18th December 2006, 04:08 PM
keeler1 Offline
Registered User
 
Join Date: Oct 2006
Posts: 201
Thanks a lot for you help. One more question though. If you had some header files stored in a directory and specified that correct path and another header file stored in the directory you are currently in and compiling the program in do you have to add another -I flag with the single '.' to have it use those header files which are in your current directory or does gcc look for header files in the current directory by defualt. I know that if no -I flag is given then gcc will use header files from the current directory. Does giving it a -I flag change that at all?
Reply With Quote
  #10  
Old 18th December 2006, 04:20 PM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
No, gcc does not look for header files anywhere except the system default directory (/usr/include if not overridden by --sysroot). So, either you specify the full path where to find the header file
Code:
#include </home/keeler/header.h>
(bad practice: unportable), or you use the double quote syntax (special case where you have the header file stored in the default directory). In any other case, the -I option is required to tell the compiler where to find the (header) files.
Reply With Quote
  #11  
Old 19th December 2006, 08:29 AM
beny Offline
Registered User
 
Join Date: Apr 2005
Posts: 123
kernel sources

Is anybody who can tell me where can I find the sources of the kernel 2.6.18-1.2798.fc6xen?
I made: yum -y install kernel-devel kernel-headers, but it installed to me another kernel sources:2.6.18-1.2868.fc6 !
Please help me!
Reply With Quote
  #12  
Old 19th December 2006, 10:32 AM
giulix's Avatar
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
Question answered here
Reply With Quote
Reply

Tags
files, header

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
where to put header files for using g++ compiler Fittersman Programming & Packaging 2 1st October 2007 10:44 AM
openGL C/C++ header files mdulzo Programming & Packaging 1 18th April 2007 08:23 AM
C header files chejose Using Fedora 15 24th January 2007 03:15 PM
Incomplete header files gruszczy Using Fedora 1 3rd January 2007 09:21 PM
Where are the X11 (xorg) header files? manojendu Using Fedora 3 20th August 2004 07:50 AM


Current GMT-time: 05:12 (Tuesday, 18-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat