LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-01-2011, 01:12 PM   #1
yjy4321
Member
 
Registered: Apr 2011
Distribution: Ubuntu
Posts: 42

Rep: Reputation: Disabled
shared library dependencies problem


I have a C program. For example output file name is "getGPS" .

case 1) If I run as a root,
$ su root
$ ./getGPS
then it runs fine.

case 2) If I run as a non-root user,
$ ./getGPS
then it runs fine.

case 3) But if I run as a non-root user,
$ sudo ./getGPS
then it does not run.
It says that "error while loading shared libraries: LIBRARY_NAME: cannot open shared object file: No such file or directory"
Also, when I do ldd command to check shared library dependencies, for case 1 and 2 it finds all library. But for case3 "sudo ldd FILE_PATH", it cannot find the library.

How do I add library for "sudo"?

P.S. I made the library it is using.
 
Old 11-01-2011, 02:14 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,061

Rep: Reputation: 769Reputation: 769Reputation: 769Reputation: 769Reputation: 769Reputation: 769Reputation: 769
Where is that library install? In your home directory somewhere, in /usr/local/lib, somewhere else? Hint: it ought to be installed in /usr/local/lib.

sudo operates in a minimum environment; i.e., it does not inherit a users environment.

If you have your library installed somewhere or other that's not one of the "standard" places, you'll need to do one of a few options.

First, let's say it's in /usr/local/lib. Check to see if you have /etc/ld.so.conf; if you do, open it in a editor and see if you have a line,
Code:
/usr/local/lib
in that file. If you do, all done.

If you have that library in some other directory, say somewhere in your home directory, first think about moving it to /usr/local/lib and if don't want to do that and you do have /etc/ld.so.conf, put the absolute path name to the directory where that library file lives.

If you don't have /etc/ld.so.conf, check around in /etc and see if the environment variable LD_LIBRARY_PATH is set somewhere (look in the subdirectories too). If you have that set somewhere, edit it and add
Code:
export LD_LIBRARY_PATH:path_to_your_library:${LD_LIBRARY_PATH}
Or, if you can't find that anywhere (it may not be there), edit /etc/profile and add the above export line to the bottom of it.

Personally, I'd move the thing to /usr/local/lib, log out, log back in and see if it just works before I did anything else.

Hope this helps some.

Last edited by tronayne; 11-01-2011 at 02:15 PM.
 
Old 11-01-2011, 04:25 PM   #3
yjy4321
Member
 
Registered: Apr 2011
Distribution: Ubuntu
Posts: 42

Original Poster
Rep: Reputation: Disabled
Thanks for your answer.

The library is in /usr/local/lib. I located /etc/ld.so.conf
Code:
$ cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
$ ls /etc/ld.so.conf.d/
qt-i386.conf
So I just added a line /usr/local/lib to the /etc/ld.so.conf file. It did not work.
I tried to add a file in the directory /etc/ld.so.conf.d/, same format as the other file I could find. It did not work.

I think this problem is with "sudo" command. sudo does not know how to find the path of libraries.
 
Old 11-01-2011, 05:26 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,467

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
I think you also have to run ldconfig after installing a new library.
 
Old 11-01-2011, 06:57 PM   #5
yjy4321
Member
 
Registered: Apr 2011
Distribution: Ubuntu
Posts: 42

Original Poster
Rep: Reputation: Disabled
Thank you all!! It works now! It was ldconfig...
 
  


Reply

Tags
libraries


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problem using shared library........ webquinty Linux - Newbie 2 02-04-2009 09:33 AM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
shared library dependencies sanjaykhuntia Programming 2 11-01-2007 08:30 PM
shared library dependencies sanjaykhuntia Linux - Enterprise 1 11-01-2007 08:30 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration