LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 06-27-2009, 02:10 AM   #1
x_gaurav
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Rep: Reputation: 0
./app: error while loading shared libraries: libfg.so: cannot open shared object file


Hi,

I am using Ubuntu 8.10
I wrote a simple program using shared library. this is what I did.

gcc -c -fPIC s1.c
gcc -c -fPIC s2.c
gcc -shared -fPIC -o libfg.so s1.o s2.o
gcc -c app.c
gcc -o app app.o -L. -lfg
./app

Ouput

./app: error while loading shared libraries: libfg.so: cannot open shared object file: Error 40

Why am I getting this error? What is error 40?
The program works if i make libfg a static library instead of a shared one.

Last edited by x_gaurav; 06-27-2009 at 02:13 AM.
 
Old 06-27-2009, 08:39 AM   #2
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 285

Rep: Reputation: 60
Have you told the loader where to find the shared library using LD_LIBRARY_PATH?

Alternatively you could use ld's rpath option, which specifies the runtime library search path of that particular program being compiled. In gcc, you can configure the rpath option by specifying it this way:
Code:
 -Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)

Last edited by fpmurphy; 06-27-2009 at 08:42 AM.
 
Old 06-27-2009, 12:32 PM   #3
x_gaurav
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks

Thanks. This worked. just a simple question though. The shared library libfg.so was in a local directory. When trying earlier i had made symbolic links to it in /lib,/usr/lib and /usr/local/lib.

Shouldn't that have worked earlier? can't the Loader simply follow the symbolic links.

Last edited by x_gaurav; 06-27-2009 at 12:42 PM.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: Franziss Linux - Newbie 10 06-28-2010 05:47 AM
error while loading shared libraries: libhid.so.0: cannot open shared object file: No misungs Linux - Software 4 06-10-2009 12:05 PM
error while loading shared libraries: libstdc++.so.5: cannot open shared object file PaulyWally Debian 2 10-18-2008 05:59 PM
error while loading shared libraries: libgvc.so.3: cannot open shared object file coolrock Slackware 6 01-17-2007 05:10 PM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM


All times are GMT -5. The time now is 02:22 AM.

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