Click to See Complete Forum and Search --> : C: include files problem


threadhead
05-04-2004, 03:40 PM
hello,

i have been trying to get some basic code working.
its some piece of userspace code that does have problems
with including the correct files when doing the preprocessing.

for example i have:

#include <linux/module.h>


on preprocessing, the standard directory is asked for that file, that is /usr/include/* for my machine.
the problem is that the files in that directory are very old, as they are left from the install when kernel 2.4.18 was
current.
i am using a 2.6 kernel now.
further on i am trying to access elements in structs for example
that only exist since 2.6 kernel series.
but as the preprocessor asks /usr/include/*, i am getting:

file.c: In function `main':
file.c:100: error: structure has no member named `core_size'

in this file.c i am trying to access an element of the struct module of the 2.6 kernels.
but as the preprocessor is referring to the old includes,
that element obviously doesnt exist.

now:
how can i update my header include files to prevent
version confusion?
or how is it possible to redirect every #include to the
current kernel source tree includes?
i tried gcc -I and -L options with the current kernel source tree includes with no success and even more errors.

thanks for your time!
threadhead

mdwatts
05-04-2004, 04:53 PM
Moved to the Programming/Script forum as you'll likely receive a few more responses from the members that frequent the forum (*cough* bwkaz :) ).

bwkaz
05-04-2004, 07:09 PM
If this is a user-space program, you DO NOT want to use the 2.6 headers -- unless you're prepared to deal with possible segfaults from glibc screwing things up!

You MUST use the headers that YOUR glibc was compiled against. Those are the ones in /usr/include. If they are too old, you're going to need to update your glibc (which means you'll have to replace the rest of your system in the process).

If you don't trust me, see the kernelnewbies FAQ on the subject (http://www.kernelnewbies.org/faq/index.php3#headers)

The official (as in from the kernel development team) thing to do with the headers is, copy the ones you need out of the kernel sources, sanitize them yourself (this is why I'd recommend using Fedora's or PLD's sanitized headers package if you recompile glibc and it doesn't break anything else), and include them with your package. This is how the xawtv package is able to use V4L2, for example -- it includes the V4L2 headers with itself. Fedora's sanitized headers don't include V4L2 support yet.

threadhead
05-05-2004, 05:39 PM
i replaced the the module.h file and made it work myself.
that worked so far, i think. thanks