LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-27-2009, 02:15 AM   #1
x_gaurav
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Rep: Reputation: 0
shared library : libfg.so: cannot open shared object file error 40


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.
 
Old 06-28-2009, 04:34 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Are you sure you haven't another libfg.so installed on your system? libfg already is the Video4Linux Frame Grabber interface. Can you try to assign another name to the shared object? E.g.
Code:
gcc -c -fPIC s1.c -o s1.o
gcc -c -fPIC s2.c -o s2.o
gcc -shared -Wl,-soname,libpippo.so.1 -o libpippo.so.1.0.1  s1.o s2.o
ln -s libpippo.so.1.0.1 libpippo.so
gcc app.c -o app -L. -lpippo
 
Old 06-28-2009, 06:29 AM   #3
x_gaurav
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Original Poster
Rep: Reputation: 0
thanks for replying. i had tried

gcc -o app app.o -L. -Wl,-rpath,. and it had worked.

when it wasn't working earlier i had created symbolic links to my libfg.so in usr/lib usr/local/lib and /lib. Any idea why it wasn't working earlier.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
./app: error while loading shared libraries: libfg.so: cannot open shared object file x_gaurav Linux - Newbie 2 06-27-2009 12:32 PM
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 12:29 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