[yocto] Yocto SDK generated - unable to compile application

Bas Mevissen abuse at basmevissen.nl
Thu Sep 20 02:50:15 PDT 2018


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
> 


More information about the yocto mailing list