Problems Compiling simple C program against custom Linux Kernel -
i compiled custom kernel defines new address family/protocol family called "af_custom"
such, include/linux/socket.h in kernel source changed, seen here(as pf_custom):
#define af_nfc 39 /* nfc sockets */ #define af_custom 40 /* custom sockets */ #define af_max 41 /* now.. */
i plan implement af_custom, quick sanity check, decided modify typical sample c socket program , see if replacing "socket(af_inet, sock_stream, 0)" "socket(af_custom, sock_stream, 0)" compile, did not. got following error when compiling gcc: 'af_custom' undeclared
assumed @ least compile, because af_custom should defined in current kernel.
the problem, see it, gcc using default kernel headers resolve "#include <sys/socket.h>" , not headers correspond custom kernel running. tried using both -i , -isystem options on gcc direct path ubuntu seems place kernel headers other kernels, seemed relevant google research, didn't help.
my question is: how can compile c program against headers running custom kernel opposed default kernel headers.
i tried this: gcc -isystem /usr/src/linux-headers-3.8.8-custom.5/ sendoncustom.c -o sendoncustom
fyi, compiled using make-kpkg. also, first question, hope understandable.
it's common practice on linux systems use "sanitized" copy of linux kernel headers build software against. probably, gcc looking headers not in /usr/src/linux, in other location (which distro-specific -- on machine, running gentoo, these headers placed in /usr/include/asm, /usr/include/linux, ...).
this page has more information this: http://headers.cross-lfs.org/
my guess need make sure when compile include path has /usr/src/linux in (or wherever modified header is), , line needs @ least come before other sanitized headers, if can't omit them entirely.
another thing note that, post, seems expect symbols defined current kernel defined everywhere - not case. whenever compile software, defines compiler sees have nothing running kernel. compiler knows how search include path try find headers specify, , examines those.
Comments
Post a Comment