构建Can';我找不到Stdio.h但我能。。。?

构建Can';我找不到Stdio.h但我能。。。?,c,ubuntu,include,C,Ubuntu,Include,我有#include(没有多余的空格)和locate stdio.h显示了一些可行的选项。然而,当我建造时,它总是说找不到。我可以用完整路径#include”/usr/include/stdio.h“包含它,但是找不到它自己的依赖项(features.h)。我试着专门寻找/usr/include文件夹,我想它应该已经很好用了,但这也无助于它找到它。所以搞什么鬼?我还拥有sudo特权。我想不出有什么好的理由让它找不到 来自make V=1 VERBOSE=1的输出 ****************

我有
#include
(没有多余的空格)和
locate stdio.h
显示了一些可行的选项。然而,当我建造时,它总是说找不到。我可以用完整路径
#include”/usr/include/stdio.h“
包含它,但是找不到它自己的依赖项(features.h)。我试着专门寻找/usr/include文件夹,我想它应该已经很好用了,但这也无助于它找到它。所以搞什么鬼?我还拥有sudo特权。我想不出有什么好的理由让它找不到

来自
make V=1 VERBOSE=1的输出

******************** Release Build **********************
make -C /lib/modules/4.15.0-58-generic/build SUBDIRS=/home/username/project modules 
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-58-generic'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \
echo >&2;                           \
echo >&2 "  ERROR: Kernel configuration is invalid.";       \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
echo >&2 ;                          \
/bin/false)
mkdir -p /home/username/project/.tmp_versions ; rm -f /home/username/project/.tmp_versions/*                                        */
make -f ./scripts/Makefile.build obj=/home/username/project
******************** Release Build **********************
  gcc -Wp,-MD,/home/username/project/.file_main.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/5/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -DCC_HAVE_ASM_GOTO -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -DCHARACTER_DRIVER -DCUSTOM_LOGIC -DOEM_001_CUSTOM_LOGIC -DNO_STATS_DEBUG  -DMODULE  -DKBUILD_BASENAME='"file_main"'  -DKBUILD_MODNAME='"file"' -c -o /home/username/project/file_main.o /home/username/project/file_main.c
In file included from /home/username/project/file_main.c:13:0:
/home/username/project/file.h:10:19: fatal error: stdio.h: No such file or directory
compilation terminated.

您需要使用
printk
,而不是
printf
。它的定义在
linux/printk.h
中,而不是
stdio.h

下次提问时,请在问题中包含这些详细信息


您的构建无法找到
stdio.h
的原因是它在内核源代码中不可用,并且您正在使用
-nostdinc
进行编译
-nostinc
会导致忽略所有默认搜索路径。

如果编译器找不到
,它可能配置错误/安装错误。是否使用
-nosdinc
编译?命令行调用是什么?查看以了解搜索的路径。如果运行
make-n
,它将只打印命令而不执行它们。您可以复制和编辑这些文件以在此处显示它们。但是,即使使用标准的
make
调用,默认情况下也会打印命令。我的问题是为什么找不到stdio,而不是如何调试或打印内核的语句(这将是一个后续问题,因为printk不适合我的需要)。现在知道它找不到了“因为内核不能使用stdio并且在构建过程中以某种方式包含了-nostdinc标志”(虽然我不知道为什么或者如何),我现在可以继续讨论其他问题。如果您更新了答案,我可以接受。@CodeMonkey请参见编辑。我仍将保留原稿(供将来参考),但我添加了一条关于
stdio.h
的注释,这很公平。如果我知道内核驱动程序的处理方式不同,我可能知道会包含这些信息,但我可能已经知道了我的答案:-p