![]() |
| | #1 |
| Registered User Join Date: Oct 2009
Posts: 1
| including linux header files Paticularly, I was trying to find the task_struct definition which is supposedly located in sched.h. One site told me it was in /usr/include/linux which it was, however it didn't contain the definition of task_struct. Another site told me it was in /usr/src/linux but I had no such directory so I looked in /usr/src/linux-headers-2.6.28-15/include and there was another sched.h that contained the definition of task_struct. However, the site contained some code snippets that included the sched.h file in this manner #include <linux/sched.h> However, when I do this, it points me to the sched.h in my /usr/include directory which doesn't contain the task_struct definition. So am I suppose to include it like this? #include </usr/src/linux-header-2.6.28-15/include> Or am I suppose to make a symbolic link from /usr/src/linux to usr/src/linux-header-2.6.28-15/include? Or do I copy the headers from usr/src/linux-header-2.6.28-15/include to /usr/include/linux? I don't know, I'm confused, and if someone could clarify I would appreciate it. By the way the site I was looking at was this one: Learning about Linux Processes LG #133 If you look at the 7th code listing, they include the header as linux/sched.h |
| jshowa is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| My basic suggestion is to see what your system thinks it is, by typing something like "man task_struct" (or maybe "apropos task_struct") and reading the documentation. Having said that, usr/src/linux-headers-2.6.28-15/include is certainly a possible path, but it's not where I'm sort of expecting that to be. I'm assuming you installed the linux devel package or source package or whatever it's called and that's what you got? Are you not actually running 2.6.28-15 yourself? (If you had two different versions of the kernel running around, then it would make sense to have the versions in the path.) |
| tabstop is offline | |
| | #3 |
| Jaxom's & Imriel's Dad Join Date: Aug 2006 Location: Alabama
Posts: 801
| You could also update your Linux Headers (this should be an RPM or whatever for most systems). If it is not, then look for Linux Headers -- these are sanitized Linux headers from the kernel -- not just a copy of the Linux kernel headers. |
| Kennedy is offline | |
| | #4 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| Create a symlink -- that's what everyone else does.
__________________ bit∙hub [bit-huhb] n. A source and destination for information. |
| bithub is offline | |
| | #5 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
Otherwise, particularly if you are distributing this, you might want to cut and past the definition right in if there is some question about it not being present on a normal system.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS | |
| MK27 is offline | |
| | #6 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| It's actually critical that you NOT replace the headers in /usr/include. These are the headers which glibc was compiled against. If you replace them, you may end up with broken binaries when you try to compile something. Strictly, you are supposed to recompile glibc when you upgrade the kernel, although almost nobody ever does that, since the exposed kernel structures change only rarely. The correct thing to do is to provide the path to the correct headers using the -I option to gcc.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
| | #7 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
What you are saying makes sense, but I think it is very theoretical; as you say, "no body actually does that...". Strictly, I think you should then recompile all the tools (gcc, etc) then recompile the kernel again, then recompile glibc again. ![]() Just a comment.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS Last edited by MK27; 10-19-2009 at 02:29 PM. | |
| MK27 is offline | |
| | #8 | |
| Jaxom's & Imriel's Dad Join Date: Aug 2006 Location: Alabama
Posts: 801
| Quote:
| |
| Kennedy is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Including header files | Emeighty | C++ Programming | 5 | 08-09-2008 03:02 PM |
| Can we have vector of vector? | ketu1 | C++ Programming | 24 | 01-03-2008 05:02 AM |
| Header Files | Volair | C Programming | 2 | 12-09-2005 10:51 AM |
| need help with menu program and header files | DFC | C++ Programming | 12 | 12-07-2005 12:09 PM |
| What /what not to put in header files | Just | C Programming | 1 | 12-14-2002 10:45 AM |