AnsweredAssumed Answered

Cross-Compiling using makefile

Question asked by chandra sekhar on Jun 15, 2016
Latest reply on Jun 19, 2016 by chandra sekhar

We have one existing application source which uses Makefile which set the compiler with something like CC=$(CROSS_COMPILE)gcc.

I have two variables in makefile CROSS_COMPILE and SYSROOT, i am setting these variables as shown below

# export ARCH=arm

# export CROSS_COMPILE=<path to cross compiler prefix> (e.g./opt/poky/1.5.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/ arm-poky-linux-gnueabi-)

#export SYSROOT=/opt/poky/1.8/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi

# make clean

# make

If I give make I am getting the below error.

../../Outils/GLOG/GLOG/src/IniParser/dictionary.h:36:19: fatal error: stdio.h: No such file or directory

#include <stdio.h>

                  ^

compilation terminated.

 

Later I checked whether sysroot is set or not by using this command

$ arm-poky-linux-gnueabi-gcc -print-sysroot

And it gave output /not/exist it means sysroot is not set

 

So I have added --sysroot to my CFLAGS in Makefile and gave make

It gave the below errors

building .so.1.0

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crt1.o: No such file or directory

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crti.o: No such file or directory

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crtbegin.o: No such file or directory

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc_s

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lc

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find -lgcc_s

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crtend.o: No such file or directory

/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: cannot find crtn.o: No such file or directory

collect2: error: ld returned 1 exit status

make[1]: *** [.so.1.0] Error 1

make[1]: Leaving directory `/home/linux/MorphoSmart_SDK_6.13.2.0_linux/PC/Sdk_linux/GLOG'

make: *** [lib] Error 1

linux@ubuntu:~/MorphoSmart_SDK_6.13.2.0_linux/PC/Sdk_linux$

 

.o's are getting generated, but it is throwing error when it is trying to generate library

I don't have any other way to compile other than using Makefile. Because the project has so many source files in different folders.

Can anyone suggest where I am going wrong.

Outcomes