| Linux - Kernel This forum is for all discussion relating to the Linux kernel. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-18-2009, 02:40 PM
|
#1
|
|
LQ Newbie
Registered: Mar 2009
Posts: 2
Rep:
|
how to create a driver makefile which uses header files outside current dir?
Hi
I want to build a driver for the linux kernel which uses header files not in the current directory.
== Dir tree looks like this
/foo/inc/myheader.h
/foo/driver/mydriver.c
/foo/driver/Makefile
== /driver/Makefile looks like this:
KERNELDIR=/usr/src/linux
TOPDIR=/foo
obj-m := mydriver.o
mydriver.o: mydriver.c ../inc/myheader.h
$(MAKE) -I $(TOPDIR)/inc -C $(KERNELDIR) M=`pwd` modules
== This will work until I add the following line in mydriver.c
#include <myheader.h>
At that point, it will complain that it can not find myheader.h
During compile, I see this:
make - I /foo/inc -C /usr/src/linux M=`pwd` modules
make [3] Entering Directory `/usr/src/linux'
CC [M] /foo/driver/mydriver.o
/foo/driver/mydriver.c:20:10: error: myheader.h: No such filer or directory
|
|
|
|
03-18-2009, 02:51 PM
|
#2
|
|
Senior Member
Registered: Sep 2003
Posts: 3,171
Rep: 
|
#include "inc/myheader.h"
Using <myheader.h> tells the compiler to look for the include in the standard include path. Putting it in quotes instead specifies a search relative to the directory you are compiling in.
|
|
|
|
03-18-2009, 03:31 PM
|
#3
|
|
LQ Newbie
Registered: Mar 2009
Posts: 2
Original Poster
Rep:
|
outside current dir?
#include "foo.h" does not work.
#include "inc/foo.h" also does not work.
|
|
|
|
03-20-2009, 01:54 PM
|
#4
|
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2012.8, Slack1337 DebSqueeze, +50+ other Linux OS, for test only.
Posts: 11,615
|
Suggest : Move or copy 'myheader.h' to foo/driver/ ,
then it will sit in the same directory as 'mydriver.c'
and can be included with : #include "myheader.h"
" " is for a local file, < > is for a system file,
e.g. in /usr/include/ .
.....
|
|
|
|
05-11-2009, 04:06 AM
|
#5
|
|
LQ Newbie
Registered: Apr 2009
Posts: 13
Rep:
|
i can't exactly provide you with a solution, because i'm looking in to these matters myself this time, still i think that if you haven't already looked there, there's some documentation at /usr/src/linux-`uname -r`/Documentation/kbuild/modules.txt
specially chapter 6 on include directories
Last edited by antiregulator; 05-11-2009 at 04:08 AM.
|
|
|
|
05-21-2009, 10:35 AM
|
#6
|
|
Member
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 210
Rep:
|
#include "../inc/foo.h" -> it will work
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:23 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|