stdlib.h exists but it's not found
-
I'm trying to compile an existing application in my cross-compile environment.
In the .pro file I added the include path to the actual sysroot:INCLUDEPATH += /local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/c++/8.2.0/arm-openstlinux_weston-linux-gnueabi INCLUDEPATH += /local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include
in this way some libraries are found (i.e. ssl and bits/c++config.h.
But I get an error here:/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/c++/8.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>Using the IDE, I went to that line and pressed F2: it brought me to the correct file:
/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/stdlib.h
It's weird to me because the path is exacly what I've added to the
INCLUDEPATH
variable.
So, why the IDE can find the file, while the compiler cannot? -
I'm trying to compile an existing application in my cross-compile environment.
In the .pro file I added the include path to the actual sysroot:INCLUDEPATH += /local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/c++/8.2.0/arm-openstlinux_weston-linux-gnueabi INCLUDEPATH += /local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include
in this way some libraries are found (i.e. ssl and bits/c++config.h.
But I get an error here:/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/c++/8.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>Using the IDE, I went to that line and pressed F2: it brought me to the correct file:
/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/stdlib.h
It's weird to me because the path is exacly what I've added to the
INCLUDEPATH
variable.
So, why the IDE can find the file, while the compiler cannot?@Mark81 said in stdlib.h exists but it's not found:
In the .pro file I added the include path to the actual sysroot:
This is almost never the correct way to do.
You should have an
environment-setup
script to setup your compiler. These scripts setup different environment variables. These variables must be added to the cross-compile Kit in Creator.Then it should work.
Regards
-
Thanks. I found the script you're talking about. It has a lot of variables. I need to set all of them?
SDKTARGETSYSROOT PATH PKG_CONFIG_SYSROOT_DIR PKG_CONFIG_PATH CONFIG_SITE OECORE_NATIVE_SYSROOT OECORE_TARGET_SYSROOT OECORE_ACLOCAL_OPTS OECORE_BASELIB OECORE_TARGET_ARCH OECORE_TARGET_OS CC CXX CPP AS LD GDB STRIP RANLIB OBJCOPY OBJDUMP AR NM M4 TARGET_PREFIX CONFIGURE_FLAGS CFLAGS CXXFLAGS LDFLAGS CPPFLAGS KCFLAGS OECORE_DISTRO_VERSION OECORE_SDK_VERSION ARCH CROSS_COMPILE
-
A couple of things come to mind that you should be aware of:
- are you sure you regenerated the makefile after adding the INCLUDEPATH directives?
- if so, try switching the order of the INCLUDEPATH directives to search the C headers first, as #include_next works differently than #include
- if the inclusion is in your project code, and not in generated code, then replace <stdlib.h> with <cstdlib>, as that is the prefered inclusion for C++ code.
-
A couple of things come to mind that you should be aware of:
- are you sure you regenerated the makefile after adding the INCLUDEPATH directives?
- if so, try switching the order of the INCLUDEPATH directives to search the C headers first, as #include_next works differently than #include
- if the inclusion is in your project code, and not in generated code, then replace <stdlib.h> with <cstdlib>, as that is the prefered inclusion for C++ code.
- I ran
qmake
again - I've just do that - same error
- unfortunately that include is indeed in line75 of
ctsdlib
(/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/c++/8.2.0/cstdlib)
Anyway I agree with @aha_1980 - I guess the right way is to provide the correct environment. But appliying all of those vars it cannot build anything at all (it doesn't find the compiler). So I bet only few of them are mandatory.