Neo
Neo

Reputation: 13891

Linux: Compiling userspace code for handling driver's ioctl

I'm new to kernel compilation and am trying to cross-compile a userspace program for an existing kernel driver for an ARM board. Basically, I'm trying to access the ioctl facilities of the driver.

I'm using arm-linux-gnueabihf-gcc (4.9.2).

I can compile the kernel successfully. The userspace code looks like following

getefuse.c

#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <sys/ioctl.h> 
#include <linux/amlogic/efuse.h> //The driver's header file
....

When I try to compile the userspace code, I get entangled in a mesh of 'include' file issues. The kernel source code resides at /home/cheema/boards/linux/

$ arm-linux-gnueabihf-gcc -I/home/cheema/boards/linux/include getefuse.c
In file included from getefuse.c:7:0:
/home/cheema/boards/linux/include/linux/amlogic/efuse.h:5:24: fatal   error: mach/efuse.h: No such file or directory
#include <mach/efuse.h>
                    ^
compilation terminated.

I try to add the missing 'include' file path. But every time I add another file path, the compiler gives the No such file or directory error for a different file.

I believe I have to use kernel's config files(Makefile??) to get out of this mess, but don't know how.

Upvotes: 0

Views: 1157

Answers (1)

srd
srd

Reputation: 1267

Looks like the file efuse.h includes mach/efuse.h. But mach is only defined under Kernel build system. It does not mean anything to cross-compiler at user-space.

You need to include only the file that has the ioclt number. If it is mach/efuse.h, then include only that file as #include <path_to_file>

You should be able to identify your mach, it depends on your board.

Upvotes: 1

Related Questions