问题
I'm building an System with Yocto/poky (morty branch). Building the image and the sdk works fine.
I've installed the SDK on an machine (other than the build machine) to cross compile a tool.
I've loaded the environment with
source /opt/mydistro/2.2.1/environment-setup-cortexa7hf-neon-vfpv4-poky-linux-gnueabi
Building a test file with
arm-poky-linux-gnueabi-gcc test.cpp
will fail with message
/opt/mydistro/2.2.1/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.2.0/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
Compilation with explicit sysroot
arm-poky-linux-gnueabi-gcc test.cpp --sysroot=/opt/mydistro/2.2.1/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/
fails with
... include/gnu/stubs.h:7:29: fatal error: gnu/stubs-soft.h: No such file or directory ...
Why is this not working? What is missing?
回答1:
Well, that you can't directly use the cross-compiler is due to sysroot-poising. See yocto built tool chain search path issue.
Thus, you should always use $CC
instead of directly using the cross-compiler. Using $CC
will not only specify the sysroot, but also specify things like -march=...
, -mfloat-abi=...
, -mtune=...
, etc (the exact number of options is depending on what machine you're building for). That should have solved all your problems.
回答2:
In my case one solution to compile and link my example was to use the following command:
arm-poky-linux-gnueabi-gcc --sysroot=/opt/mydistro/2.2.1/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/ -mfloat-abi=hard
来源:https://stackoverflow.com/questions/43187384/stdint-h-no-such-file-or-directory-error-on-yocto-sdk