简体   繁体   English

Build 找不到 Stdio.h 但我可以...?

[英]Build Can't Find Stdio.h But I Can...?

I have #include <stdio.h> (no extra spaces) and locate stdio.h shows a few viable options.我有#include <stdio.h> (没有多余的空格)并locate stdio.h显示了一些可行的选项。 And yet, when I build, it always says it can't be found.然而,当我构建时,它总是说找不到。 I can include it with a full path #include "/usr/include/stdio.h" , but then its own dependencies (features.h) can't be found.我可以使用完整路径包含它#include "/usr/include/stdio.h" ,但是找不到它自己的依赖项 (features.h)。 I tried specifically sourcing the /usr/include folder which I imagine should already be good to go anyway, but that doesn't help it find it either.我尝试专门寻找 /usr/include 文件夹,我认为无论如何应该已经很好了,但这也无济于事。 So... what the heck?所以……什么鬼? I'm also building with sudo privileges.我也在使用 sudo 权限进行构建。 I can't fathom a good reason for it to not be found.我想不出找不到它的充分理由。

output from make V=1 VERBOSE=1 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.

You need to use printk , not printf .您需要使用printk ,而不是printf Its definition is in linux/printk.h , not stdio.h .它的定义在linux/printk.h ,而不是stdio.h

Please include these details in your question the next time you ask.下次您提问时,请在您的问题中包含这些详细信息。

The reason your build is not able to find stdio.h is because it's not available in the kernel sources, and you're compiling with -nostdinc .您的构建无法找到stdio.h的原因是它在内核源代码中不可用,而您正在使用-nostdinc编译。 -nostdinc causes all the default search paths to be ignored. -nostdinc导致所有默认搜索路径被忽略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM