LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   shared library : libfg.so: cannot open shared object file error 40 (http://www.linuxquestions.org/questions/programming-9/shared-library-libfg-so-cannot-open-shared-object-file-error-40-a-735969/)

x_gaurav 06-27-2009 02:15 AM

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.

colucix 06-28-2009 04:34 AM

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


x_gaurav 06-28-2009 06:29 AM

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.


All times are GMT -5. The time now is 07:18 PM.