[yocto] Yocto SDK generated - unable to compile application

Bas Mevissen abuse at basmevissen.nl
Thu Sep 20 05:23:06 PDT 2018


On 2018-09-20 12:28, Evan O'Loughlin wrote:
> ________________________________________
> From: Bas Mevissen [abuse at basmevissen.nl]
> Sent: 20 September 2018 10:50
> To: Evan O'Loughlin
> Cc: yocto at yoctoproject.org
> Subject: Re: [yocto] Yocto SDK generated - unable to compile 
> application
> 
> On 2018-09-20 11:40, Evan O'Loughlin wrote:
>> -----Original Message-----
>> From: Bas Mevissen [mailto:abuse at basmevissen.nl]
>> Sent: 20 September 2018 10:12
>> To: Evan O'Loughlin <evan.oloughlin at vitalograph.ie>
>> Cc: yocto at yoctoproject.org
>> Subject: Re: [yocto] Yocto SDK generated - unable to compile
>> application
>> 
>> On 2018-09-20 10:08, Evan O'Loughlin wrote:
>>> Hello,
>>> 
>>> I’m having an issue when I try to use the SDK generated by my yocto
>>> instance.
>>> Currently I have yocto set-up to correctly build my image – this all
>>> works well.
>>> 
>>> I've built the SDK in the following ways:
>>>    * bitbake {image} –c populate_sdk
>>>    * bitbake meta-toolchain-qt5
>>>    * bitbake {image-sdk} using a separate recipe with the options:
>>>        - require {image}.bb
>>>        - IMAGE_FEATURES += " dev-pkgs tools-sdk tools-debug
>>> eclipse-debug debug-tweaks"
>>>        - IMAGE_INSTALL += "kernel-devsrc"
>>>        - inherit populate_sdk populate_sdk_qt5
>>> 
>>> 
>>> When I try to use the generated SDKs I get the error below:
>>> Simple helloworld app:
>>>    #include <stdio.h>
>>>    #include <stdlib.h>
>>>    #include <stddef.h>
>>>    #include <cstddef>
>>> 
>>>    int main (int argc, char** argv)
>>>    {
>>>       printf("Hello World\n");
>>>       return 0;
>>>    }
>>> 
>>> Compile error:
>>>    ${CC} helloworld.c
>>>    helloworld.c:4:19: fatal error: cstddef: No such file or directory
>>>    #include <cstddef>
>>>                     ^
>>>    compilation terminated
>>> 
>>> 
>>> Have I missed a step in generating the SDK?
>>> 
>>> 
>> 
>> No, your SDK looks fine. The solution is to just remove the line
>> 
>> #include <cstddef>
>> 
>> from your c sources or use the g++ compiler (called ${CXX) in
>> Makefile) to compile the source.
>> 
>>> Regards,
>>> vitalEol
> 
>> Hi Bas,
>> 
>> I'm using the offending line in helloworld.c to highlight the issue 
>> I'm
>> seeing.
>> 
>> My main program is a Qt application where I see the same issue when
>> trying to build in QtCreator.
>> 
>> My issue relates to the fact that several include files are not
>> readily available after 'sourcing' the environment setup.
>> 
>> Do I need to adjust/include other recipes when building the SDK?
>> 
> 
> I might be wrong, but this looks like you are using the gcc compiler
> instead of the g++ one. See the second part of my answer.
> 
> To check your environment, check in your sdk that the file cstddef
> exists somewhere in /usr/include. Example from a Fedora Linux system:
> 
> $ find /usr/include -name cstddef
> /usr/include/c++/8/cstddef
> 
> If I compile your example with "gcc" on that system, I get the same
> error. With "g++", is is fine. It automatically find the cstddef header
> file in the /usr/include/c++/8 directory.
> 
> Hope this helps,
> 
> (and please do not top post as that makes a mail thread unreadable)
> 
> -- Bas.
> 
> 
>> Regards,
>> Evan
>> 
> 
> Hi Bas,
> 
> Apologies for top-posting previously.
> 
> using ${CC}, ${CPP} or ${CXX} all show the same error relating to not
> finding the required include
> 
> cstddef is available in the cross-compiler toolchain:
> $ find . -name cstddef
> ./sysroots/armv7ahf-neon-linux-gnueabi/usr/include/c++/6.2.1/cstddef
> ./sysroots/armv7ahf-neon-linux-gnueabi/usr/include/boost/compatibility/cpp_c_headers/cstddef
> 

That looks fine.

> and is also available on my system:
> $ find /usr/include -name cstddef
> /usr/include/c++/5/cstddef
> /usr/include/c++/4.7/cstddef
> /usr/include/c++/4.8/cstddef
> 
> 
> ${CC} --version && ${CPP} --version && ${CXX} --version
> arm-linux-gnueabihf-gcc (Linaro GCC 6.2-2016.11) 6.2.1 20161016
> Copyright (C) 2016 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is 
> NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
> PURPOSE.
> 
> arm-linux-gnueabihf-gcc (Linaro GCC 6.2-2016.11) 6.2.1 20161016
> Copyright (C) 2016 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is 
> NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
> PURPOSE.
> 
> arm-linux-gnueabihf-g++ (Linaro GCC 6.2-2016.11) 6.2.1 20161016
> Copyright (C) 2016 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is 
> NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
> PURPOSE.
> 

I tried with an Freescale i.MX6 SDK for Sumo and that compiled fine with 
${CXX}.

It is a bit of guessing now. Maybe somewhat more information might help:

What version of Yocto are you using? What layers are included? What 
machine?

Are you sure this is the cross compiler belonging to the SDK?

Did you maybe move the SDK install location and not adapt the 
environment file?
Please check this with "echo ${SDKTARGETSYSROOT}" and "echo ${CXX}"


> 
> Regards,
> Evan


More information about the yocto mailing list