LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 03-23-2012, 12:50 PM   #1
errantes
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Rep: Reputation: Disabled
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.
 
Old 03-23-2012, 02:31 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
You need make sure makefile use LDFLAGS when doing linking.
 
Old 03-26-2012, 04:17 AM   #3
errantes
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-26-2012, 04:46 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.

.
 
Old 03-26-2012, 01:25 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 03-26-2012, 02:33 PM   #6
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
/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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Compilation error - GSL library + MPI Benchmark Library = undefined reference quadpixels Programming 5 07-08-2012 03:33 AM
how to include the path of exe in the ld library path? malli42108 Linux - Networking 10 09-17-2009 09:21 AM
static library cross compilation kskkumar Programming 3 03-20-2007 12:35 PM
Cross-compilation radhapriya Linux - Software 0 08-11-2003 07:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration