dynamic linking


 
Thread Tools Search this Thread
Top Forums Programming dynamic linking
# 1  
Old 05-23-2007
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
# 2  
Old 05-23-2007
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
# 3  
Old 05-23-2007
unfortunately i am allowed to change LD_LIBRARY_PATH outside my application. i was trying to replace this library inside the application.
# 4  
Old 05-23-2007
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
# 5  
Old 05-23-2007
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Linking .so into C program

I have a C binary file(.so as extension) which is delivered by a product. How do i use this functionalities of this .so file in my C program? How can in link the .so to my C program? (1 Reply)
Discussion started by: vkca
1 Replies

2. Programming

Database Linking

Hey, i cant seem to find #include<sqlite3> in the libraries, even after installing sqlite3 in linux. how do i solve this problem (1 Reply)
Discussion started by: gregarion
1 Replies

3. UNIX for Advanced & Expert Users

Sql dynamic table / dynamic inserts

I have a file that reads File (X.txt) Contents of record 1: rdrDESTINATION_ADDRESS (String) "91 971502573813" rdrDESTINATION_IMSI (String) "000000000000000" rdrORIGINATING_ADDRESS (String) "d0 movies" rdrORIGINATING_IMSI (String) "000000000000000" rdrTRAFFIC_EVENT_TIME... (0 Replies)
Discussion started by: magedfawzy
0 Replies

4. UNIX for Dummies Questions & Answers

is linking possible?

how would i link 2 files together? is it the same as copying? (1 Reply)
Discussion started by: trob
1 Replies

5. Solaris

linking in solaris9

at the end of the compilation in solaris 9. it is showing link error. like..... ld: fatal: library -lgthread-2.0 not found failed to create the binary the library is in /usr/lib and in /usr/local/lib the lib file is present --->libgthread.2.0.so ......etc if i remove... (3 Replies)
Discussion started by: biswajithit
3 Replies

6. Programming

dynamic linking of folder name in makefile

i will tell my problem with example: if i have a folder name called sree1.7.3 i know the starting name say sree and also path say /usr/lib. so i want the folder name. and how can i link this folder in makefile thank u sree (1 Reply)
Discussion started by: phani_sree
1 Replies

7. Programming

differeEEK!nce between static and dynamic linking

hello, friends i would like to know what is the differnce between static library and dynamic library? How will u create them and what are there uses? (1 Reply)
Discussion started by: vijaya2006
1 Replies

8. Programming

Linking with gcc

Forgive as I am new to the gcc compiler and to linux. I am trying to compile/link a program for the first time and am receiving an error complaining about the crtbegin.o file. I use the -v option and get the following: Using built-in specs. Configured with: ../configure --enable-threads=posix... (1 Reply)
Discussion started by: jbeauchamp
1 Replies

9. Programming

dynamic linking in gcc

Hai Friends how to use dynamic library linking in gcc. I have create the library files and placed it in /lib directory and my program should refer to that library dynamically.. How do i do that.. Thanks in advance (0 Replies)
Discussion started by: collins
0 Replies

10. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o builtin.so Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies
Login or Register to Ask a Question