不能包含 linux/cred.h 头文件 : "No such file or directory"

标签 c linux header include kernel

我目前正在尝试包含 cred.h 头文件,因为我想重写 struct cred 中的 uid、guid ……。但是包含失败并显示错误消息“ fatal error :linux/cred.h:没有这样的文件或目录”。我想这是因为我不能将内核头文件包含到用户空间程序中。有什么办法可以解决这个问题吗?


更新:

啊我忘了说我想用android ndk-build命令编译它,但是有一个类似的选项n find 命令给出了这个输出:

sudo find / -name cred.h
/tmp/mozilla_alex0/cred.h
/home/alex/Android/Sdk/goldfish/include/linux/cred.h
/usr/src/linux-headers-4.4.0-24/include/linux/cred.h
/usr/src/linux-headers-4.4.0-21/include/linux/cred.h

现在我尝试了以下方法:

$ ndk-build -I /usr/src/linux-headers-4.4.0-21/include/linux/ 
[armeabi] Compile thumb  : futex_exploit <= exploit.c
/home/alex/Android/libfutex_exploit-master/libfutex_exploit-master/jni/exploit.c:34:18: fatal error: cred.h: No such file or directory
 #include <cred.h>
                  ^
compilation terminated.

当尝试用 gcc 编译文件时,我得到了同样的错误:

$ gcc -I/usr/src/linux-headers-4.4.0-21/include/linux/ exploit.c -o exploit
In file included from /usr/include/stdio.h:33:0,
                 from exploit.c:21:
/usr/src/linux-headers-4.4.0-21/include/linux/stddef.h:4:31: fatal error: uapi/linux/stddef.h: No such file or directory
compilation terminated.

最佳答案

找到所需的文件 cred.h 并将其放入编译器将搜索它的文件夹中。

gcc ..... -I<include folder> .....

关于不能包含 linux/cred.h 头文件 : "No such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38101480/

相关文章:

python - 在 C/openCL 中寻址 vector 元素

C语言中的CLOCKS_PER_SEC找到time.h库

c - 将随机生成的值从子进程发送到父进程

c++ - 为什么在同一个 cpp 文件中包含 header 和前向声明包含的类?

c - 两次成功读取后,与 fseek() 一起使用时 fgetc() 不起作用

linux - BlueZ:不使用 sdptool 命令添加服务、属性和配置文件

linux - linux中如何使用for循环统计并打印出一组单词

linux - 使用 sar、sysstat 获取每个进程的内存使用情况

C++ header 包含

C错误: "Undefined reference to ' sf_open'"from libsndfile