7 Replies Latest reply on Feb 16, 2016 9:12 PM by shaka

    Latest cross compile toolchain(glibc) for quark doesn't work


      Hi, all


      I met some problems when using the self-built cross compile toolchain(glibc) for Quak. Can any help? Thanks!


      From this site Download Intel® Quark™ BSP I get Board_Support_Package_Sources_for_Intel_Quark_v1.2.0.7z and Quark_BSP_BuildGuide_329687_009.pdf.

      Following the build guide, I have suceessfully built out the cross compile toolchain installer(iot-devkit-glibc-x86_64-image-full-i586-toolchain-1.7.2.sh) on my Ubuntu-12.04 machine by "bitbake image-full" and "bitbake image-full -c populate_sdk".


      But, it failed when I try to compile/link some program, who call the 'fputc' or 'fgetc' methods, using this toolchain.


      // test1.c

      #include <stdio.h>

      int main () {

        fputc('a', stdout);

        printf ("hello world! \n");

        return 0;

      In a new terminal window, source the environment setup script and compile test1.c. A link error occurs like this:

      shaka@shaka-VirtualBox:~/test$ source /opt/iot-devkit/1.7.2/environment-setup-i586-poky-linux

      shaka@shaka-VirtualBox:~/test$ $CC test1.c

      /tmp/cctVzDzW.o: In function `main':

      test1.c:(.text+0x50): undefined reference to `__fputc_unlocked'

      collect2: error: ld returned 1 exit status

      From google I got this explain https://www.uclibc.org/FAQ.html#miscompile saying that:


      My package builds fine but link fails with errors like "undefined reference to __fputc_unlocked", who do I blame?!

      This error crops up when a build system mixes system headers (say glibc) with the target headers (say uClibc). Make sure your build system is not including extraneous include options (-I) and double check that it is using the correct compiler. Many build systems incorrectly force things like -I/usr/include or -I/usr/local/include or -I${prefix}/include (which usually just expands to -I/usr/include)




      It seems that the cross toolchain mixes glibc and uclibc. To prove this I wrote another program:

      // test2.c

      #include <stdio.h>

      int main () {

      #ifdef __UCLIBC__

        printf (" __UCLIBC__ is defined. \n");


        return 0;

      Compile test2.c with the cross toolchain and run on the Galileo Gen1 board. I got the output "__UCLIBC__ is defined.".  So I think there is something wrong with the toolchain. The header file /opt/iot-devkit/1.7.2/sysroots/i586-poky-linux/usr/include/stdio.h has been attached for your reference. I doubt this file is not for glibc but for uclibc.



      And, what's more:

      If I source the file environment-setup-i586-poky-linux which is generated by "bitbake image-full" and "bitbake meta-ide-support", anything will be OK. No link error for test1.c and no output when running test2.



      Is there anyone know what cause this issue and how to fix? Thanks!


      (BTW, I have tried both 32 bit and 64 bit machine to built the toolchain and the issue exist all the same.)