The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
dynamic linking of folder name in makefile phani_sree High Level Programming 1 07-25-2007 05:49 AM
differeEEK!nce between static and dynamic linking vijaya2006 High Level Programming 1 03-03-2006 05:12 AM
Linking with gcc jbeauchamp High Level Programming 1 02-14-2005 10:26 AM
dynamic linking in gcc collins High Level Programming 0 09-14-2004 08:48 AM
Linking problem while linking to shared library laho High Level Programming 6 03-16-2004 06:01 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2007
Registered User
 

Join Date: Sep 2005
Location: india
Posts: 78
dynamic linking

Hi,

Could any one tell me solution for this.

i have a library in my /usr/lib and latest in /myhome/lib/ (thay differ functionality symbols my application uses symbols from latest lib).



when compile and link my application , every thing goes fine

but when running the application ld loads this library from /usr/lib
i want it to take this libary from /myhome/lib instead of /usr/lib
how can i tell this to ld.so

i heard of LD_CONFIG env variable(if any one knows how to use it plz let me know)

any help would be highly appreciated
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-23-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
ELF systems (Solaris, xxxBsd, Linux, Tru64 ) use LD_LIBRARY_PATH
AIX uses LIBPATH
IRIX uses LD_LIBRARYN32_PATH and LD_LIBRARYN64_PATH
HPUX PA-RISC systems use SHLIB_PATH
Reply With Quote
  #3 (permalink)  
Old 05-23-2007
Registered User
 

Join Date: Sep 2005
Location: india
Posts: 78
unfortunately i am allowed to change LD_LIBRARY_PATH outside my application. i was trying to replace this library inside the application.
Reply With Quote
  #4 (permalink)  
Old 05-23-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Set the SONAME of the library to it's full path

as in $(CC) -shared -W1,-soname,/myhome/lib/libfoo.so foo.o -o /myhome/libfoo.so

then when an application links against it the full path will be recorded.

confirm with ldd.

Also you may want to look at -rpath
Reply With Quote
  #5 (permalink)  
Old 05-23-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,491
If this is production code, don't link against your own directory tree. Terrible idea. Instead compile your shared library into a archive (.a). Link statically against the .a file.

cc myprogram.c /myhome/lib.libwhatever.a -o myprogram

The executable image will then run pretty much anywhere, on any system that supports the archictecture on your development system - and that has the same libc The downside is that the app will use more memory.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0