Cross compiling a application using Shared libraries
<p>I am having a existing application which compiles and executes in GCC.
I am cross compiling the same application, I am able to cross compile and generate the shared libraries. But when I try to use the shared libraries for linking to a application it is giving the following errors </p>

<pre><code>arm-poky-linux-gnueabi-gcc MSO_Version.o MSO_Connect.o MSO_errors.o -o bin/MSO_Version_shared -Wall -g -Os -fPIC -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk -I../include -I../wsq -I/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk/usr/include/ -L/opt/poky/1.8/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi/usr/lib -L../lib -L/opt/poky/1.8/sysroots/i686-pokysdk-linux/lib -L/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/lib -L/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk/usr/lib -lMSO -lMSOComm -lusb
/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/ld: skipping incompatible /opt/poky/1.8/sysroots/i686-pokysdk-linux/lib/libgcc_s.so.1 when searching for libgcc_s.so.1
/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 /lib/libc.so.6
/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 /usr/lib/libc_nonshared.a
/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 /lib/ld-linux-armhf.so.3
collect2: error: ld returned 1 exit status
make[1]: *** [MSO_Version_shared] Error 1
make[1]: Leaving directory `/home/linux/ESYS-IMP-LINUXAPP-SUF-24092012-V0.01/Internal Release/ESYS-IMP-LinuxApp-SUF-LIB-SRS-V0.01/samples'
make: *** [samples] Error 2
</code></pre>

<p>If I compile with static libraries executables are getting generated. Below is my makefile</p>

<pre><code>export CROSS_COMPILE

CC = $(CROSS_COMPILE)gcc

ifeq ($(DEBUG),yes)
CFLAGS = -Wall -g -Os -fPIC -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk


else
CFLAGS = -Wall -Os -fPIC -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk


endif

LIB_USB = -lusb
LIB_SDL = -lSDL -lSDL_ttf

LIBPATH += -L/opt/poky/1.8/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi/usr/lib
LIBPATH += -L../lib
LIBPATH += -L/opt/poky/1.8/sysroots/i686-pokysdk-linux/lib
LIBPATH += -L/opt/poky/1.8/sysroots/i686-pokysdk-linux/usr/lib
LIBPATH += -L/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk/usr/lib
LIB_STATIC_SAGEM = ../lib/libMSO.a ../lib/libMSOComm.a
LIB_SAGEM = -lMSO -lMSOComm


SRCINCLUDE += -I../include -I../wsq
SRCINCLUDE += -I/home/fsl-release-bsp/build_image/tmp/sysroots/imx6ulevk/usr/include/

EXEC_PATH = bin
EXEC_STATIC = MSO_Version #MSO_TestBio MSO_TestThread
EXEC_SHARED = MSO_Version_shared #MSO_TestBio_shared

MSO_Version_SRC = MSO_Version.c MSO_Connect.c MSO_errors.c
MSO_Version_OBJ = $(MSO_Version_SRC:.c=.o)

.PHONY: all
all: $(EXEC_STATIC) $(EXEC_SHARED)

%.o: %.c
        $(CC) -c $(CFLAGS) $(SRCINCLUDE) $&lt; -o $@

.PHONY: MSO_Version MSO_Version_shared
MSO_Version: $(MSO_Version_OBJ)
        $(CC) $(MSO_Version_OBJ) -o $(EXEC_PATH)/MSO_Version $(CFLAGS) $(SRCINCLUDE) $(LIB_STATIC_SAGEM) $(LIB_USB)
MSO_Version_shared: $(MSO_Version_OBJ)
        $(CC) $(MSO_Version_OBJ) -o $(EXEC_PATH)/MSO_Version_shared $(CFLAGS) $(SRCINCLUDE) $(LIBPATH) $(LIB_SAGEM) $(LIB_USB)
</code></pre>

<p>You can see I am generating two executables one with the static library and other with  shared library. 
I am using poky 1.8 and kernel is 2.6.38. Using NXP IMX6ULEVK board. 
Can anyone tell me where I am going wrong</p>