0

I am building a linux device using make and i need to use string.h in my device. I tried to add /usr/include to make file but it does not work. can any one help me on adding another include path to make file. my make file is

KBUILD_CFLAGS += -w

obj-m += netlinkKernel.o

all:
    make -w -C /lib/modules/$(shell uname -r)/build CPPFLAGS="usr/include/" M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
user2714949
  • 399
  • 2
  • 3
  • 11

2 Answers2

2

That's because just usr/include/ isn't a proper compiler flag. You need to use e.g. -I/usr/include/.

However, using libraries from userspace in a kernel driver might not work as you expect it to, like not at all. The kernel should have have it's own string library (including the "string.h" header file) that you should use.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • i used it but still it is same it cant find string.h – user2714949 Nov 28 '13 at 15:47
  • @user2714949 My guess is that the kernel makefiles clean up the flags, to not include any user-space libraries. – Some programmer dude Nov 28 '13 at 15:54
  • can you point me to a solution i can use string.h to build the module. I have some string operation need to be done inside the module. I can add the header file to module directory but string.h uses some other header files and they use some other header files. this is a chain :( – user2714949 Nov 28 '13 at 19:00
  • Yes, You should not use any uspace libraries or header files in the kernel programming. You need to use the functions provided by the kernel only. For string functions you need to include linux/string.h in your kernel program. #include – knare Nov 29 '13 at 06:23
0

it seems like we can not use standard header files in kernel programming. Thanks for your help

user2714949
  • 399
  • 2
  • 3
  • 11