LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2007, 02:11 AM   #1
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Rep: Reputation: 15
Question How to (temporarily) add a library search path?


I try to execute a program. It gives me this "cannot open shared object file: No such file or directory" error...

I know I can add it to ld.so.conf and run ldconfig. But that's not what I want... For example on windows you can just copy the responsible "dll" to the executable directory and it works as well.

But how can I achieve the same in Linux? I tried already making a softlink with the same name to the executable directory, but that didn't work...


Anyone knows ?


Greetz,
Steven
 
Old 06-24-2007, 05:16 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Maybe create the softlink into a directory that is always checked for libs, like /usr/lib for example? Or define the library variable manually with export.. (note: I don't remember what it's exactly called, check using console).
 
Old 06-24-2007, 05:21 AM   #3
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Original Poster
Rep: Reputation: 15
Sorry I found it while googling.

For someones reference:

LD_LIBRARY_PATH=/your/dir <executable>

in my case it was:
me@mydesktop:/var/tmp/my_program$ LD_LIBRARY_PATH=/var/tmp/my_libs ./my_program
 
Old 07-03-2007, 07:59 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
If you are the developer of the program, use -rpath-link path and -rpath path when linking. -rpath-link provides a search path for link resolution to make sure you have a good link, but does nothing for run-time. When you use -rpath, that adds a path to the binary so that at run-time ld will search that path for dependent libraries.
ta0kira
 
Old 07-03-2007, 08:06 AM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Example: program needs library libprogram.so which is located at ../lib from the build directory, and after installation it will be located in the same path as program. You would use -rpath-link ../lib -rpath . when linking program to libprogram.so.
ta0kira
 
  


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
Can I Reset Xserver Library File Search Path? Daniel N. Santiago Linux - Newbie 1 08-18-2006 12:45 PM
How do I add library path? scc28y Linux - Newbie 5 03-18-2005 10:56 PM
I need to add a directory to the search path johnjafa Linux - Software 1 01-06-2005 01:43 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM
linking downloaded c library to global search path syoh Programming 1 10-17-2003 01:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:49 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