4

How could I include a linux header file? I read from the web that the header file is in /usr/include. However, the header file I need is not in that directory; it is in /usr/src/kernels/2.6.32.../include/linux/.

I tried to include the file using the full path. However, the file itself includes other header files as well. Hence, the compiler couldn't find the other header files when I compile.

How could I include the header file in my program and compile the program?

2

3 Answers 3

10

If you are on Ubuntu, install libcpufreq-dev. This will give you the cpufreq.h header at /usr/include/cpufreq.h, which you can include from your code with #include <cpufreq.h>.

Sign up to request clarification or add additional context in comments.

1 Comment

Get the header installed is the best solution.
5

By default, gcc searches the following directories for header files:

/usr/local/include/
/usr/include/

and the following directories for libraries:

/usr/local/lib/
/usr/lib/

The compiler options -I and -L add new directories to the beginning of the include path and library search path respectively.

Comments

1

You may add to your gcc command line -I (for "includes") options which specify other directories to search for include files (besides or actually even instead of the normal ones like /usr/include, though it's so long since I last needed the "instead of" that I don't recall how that's done == man gcc should tell you in 5 minutes if you need to find out;-).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.