LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   cross-compilation takes the host library path (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/cross-compilation-takes-the-host-library-path-936069/)

errantes 03-23-2012 12:50 PM

cross-compilation takes the host library path
 
Hi All,
I have already cross-compiled some code end libs for arm.
Now I am trying to compile the sofia-sip package and I have some trouble with the library path.

The problem is that the linker search for some glib in the host path.

I have the library for arm and I set the LDFLAGS to reach target arm glib

Code:

export LDFLAGS=-L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/lib -L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/usr/lib
With this LDFLAGS the linker points to the host library in
“/usr/lib/libglib-2.0.so”.

I can compile if I temporarily move the arm lib in /usr/lib but when I try to compile an example project using the lib I get I have again the same problem.
In the example project makefile the /usr/lib path does not appears.

Thank you.

nini09 03-23-2012 02:31 PM

You need make sure makefile use LDFLAGS when doing linking.

errantes 03-26-2012 04:17 AM

Thank you for the answer nini09.
The LDFLAGS are used by the linker as you can see from the output of the make:

Code:

Making all in src
make[2]: Entering directory `/home/ermes/workspace/sofsip-cli-0.16/src'
/bin/sh ../libtool --tag=CC --mode=link /opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc  -g -O2  -L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/usr/lib -o sofsip_cli  sofsip_cli.o ssc_input.o libsofsip-cli-objects.la -L/home/ermes/workdir/filesys/usr/lib -lsofia-sip-ua  -L/home/ermes/workdir/filesys/usr/lib  -pthread -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0      -lreadline -lncurses -lpthread
/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc -g -O2 -o sofsip_cli sofsip_cli.o ssc_input.o -pthread  -L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/usr/lib ./.libs/libsofsip-cli-objects.a -L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/lib -L/home/ermes/workdir/filesys/usr/lib /home/ermes/workdir/filesys/usr/lib/libsofia-sip-ua.so /usr/lib/libgobject-2.0.so /usr/lib/libgthread-2.0.so -lrt /usr/lib/libglib-2.0.so -lreadline -lncurses -lpthread -Wl,--rpath -Wl,/home/ermes/workdir/filesys/usr/lib -Wl,--rpath -Wl,/home/ermes/workdir/filesys/usr/lib
/usr/lib/libgobject-2.0.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [sofsip_cli] Error 1
make[2]: Leaving directory `/home/ermes/workspace/sofsip-cli-0.16/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ermes/workspace/sofsip-cli-0.16'
make: *** [all] Error 2

The problem is that it picks libgobject-2.0.so from /usr/lib (a path which does not appear in the makefile) and the correct path is /home/ermes/workdir/filesys/usr/lib (which appears after the -L)

Thank you

knudfl 03-26-2012 04:46 AM

Quote:

The problem is that it picks libgobject-2.0.so from /usr/lib
'make' uses autotools : /usr/lib/ is first in the "library search paths".
You may be able to either exclude all system paths,
or have all those not to be first in the search path.

Use a chroot environment : Nothing outside will be used.

Or :
export LD_LIBRARY_PATH=/home/ermes/workdir/filesys/usr/lib etc. etc.

.

theNbomr 03-26-2012 01:25 PM

Your toolchain may not be built correctly. A GNU toolchain has a built-in list of places to search for libraries, and other bits. That built-in list is a function of how it was created. Try running
Code:

/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc -print-search-dirs
to see where it will look for stuff.

--- rod.

nini09 03-26-2012 02:33 PM

/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc -g -O2 -o sofsip_cli sofsip_cli.o ssc_input.o -pthread -L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/usr/lib ./.libs/libsofsip-cli-objects.a -L/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/target/lib -L/home/ermes/workdir/filesys/usr/lib /home/ermes/workdir/filesys/usr/lib/libsofia-sip-ua.so /usr/lib/libgobject-2.0.so /usr/lib/libgthread-2.0.so -lrt /usr/lib/libglib-2.0.so -lreadline -lncurses -lpthread -Wl,--rpath -Wl,/home/ermes/workdir/filesys/usr/lib -Wl,--rpath -Wl,/home/ermes/workdir/filesys/usr/lib

Check your red print-out. The libgobject-2.0.so is told to serach at /usr/lib.


All times are GMT -5. The time now is 06:25 AM.