-   Programming (
-   -   shared library : cannot open shared object file error 40 (

x_gaurav 06-27-2009 02:15 AM

shared library : cannot open shared object file error 40

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 s1.o s2.o
gcc -c app.c
gcc -o app app.o -L. -lfg


./app: error while loading shared libraries: 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 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.

gcc -c -fPIC s1.c -o s1.o
gcc -c -fPIC s2.c -o s2.o
gcc -shared -Wl,-soname, -o  s1.o s2.o
ln -s
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 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 09:59 AM.