shared library not found

Hello,

On a Centos 5.0 box, I have two versions of a library (sqlite):
(1) in /usr/lib that was installed using yum (maybe from php but I am not really sure)
(2) in /usr/local/lib that I installed myself by compiling from the source code.

My C++ program contains the following lines:

main.cpp
#include "/usr/local/include/sqlite3.h"

Makefile
SQLITE_LIB = "/usr/local/lib/libsqlite3.so"
SQLITE = -I "/usr/local/include/"

$(TARGET_APP) : main.o
$(CPP) -LLIBDIR $(FASTCGI_LIB) $(SQLITE_LIB) -o $(TARGET_APP) main.o

main.o : main.cpp
$(CPP) $(BOOST) $(SQLITE) -c -o main.o main.cpp

This compiles fine but when I run it, I am getting the error message:
symbol lookup error: app: undefined symbol: sqlite3_open_v2

I guess the shared library is not found at run time. What should I do to make it work?
Thanks

$(CPP) -LLIBDIR $(FASTCGI_LIB) $(SQLITE_LIB) -o $(TARGET_APP) main.o

How about changing the line above to this one

$(CPP) -L $(FASTCGI_LIB) /usr/local/lib/ -lsqlite3 -o $(TARGET_APP) main.o

And run ldd on the final executable to see if there is any output error ...

Thanks for the answer. I tried
$(TARGET_APP) : main.o
$(CPP) -L $(FASTCGI_LIB) /usr/local/lib/ -lsqlite3 -o $(TARGET_APP) main.o

but compilation failed with the following message:
/usr/local/lib/: file not recognized: Is a directory
collect2: ld returned 1 exit status
make: *** [lock.vrv] Error 1

Well, have another go with this line

$(CPP) -L $(FASTCGI_LIB) -L /usr/local/lib/ -lsqlite3 -o $(TARGET_APP) main.o 

$(TARGET_APP) : main.o
$(CPP) $(FASTCGI_LIB) -L /usr/local/lib/ -lsqlite3 -o $(TARGET_APP) main.o
doe compile indeed ( I just took off the -L before $(FASTCGI_LIB) but I am back to my previous problem since the final executable returns:
symbol lookup error: ./app: undefined symbol: sqlite3_open_v2

Since the program compiles, the sqlite_open_v2 is found in both the header and the shared library but for some reason, at run-time, it fails.

post the output of the below commands

ldd ./app
echo $LD_LIBRARY_PATH

hello,
ldd ./app
linux-gate.so.1 => (0xffffe000)
libfcgi++.so.0 => /usr/local/lib/libfcgi++.so.0 (0x4000c000)
libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x464d9000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x46dfb000)
libm.so.6 => /lib/libm.so.6 (0x46dab000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x46ded000)
libc.so.6 => /lib/libc.so.6 (0x46c69000)
libfcgi.so.0 => /usr/local/lib/libfcgi.so.0 (0x40012000)
libnsl.so.1 => /lib/libnsl.so.1 (0x46543000)
libpthread.so.0 => /lib/libpthread.so.0 (0x46dd4000)
/lib/ld-linux.so.2 (0x4629a000)
echo $LD_LIBRARY_PATH

the latest commands returns a blank line. Thank you for your help

are you using sqlite3_xxxx() or sqlite_xxxx() calls? It looks like your not using the V3 API.

ie:

sqlite3_open()

or

sqlite_open()

I am trying to use sqlite3_open_v2, which I believe is in sqlite 3.5.4 (the one I am trying to link to in /usr/local/lib), but is not member of sqlite 3.3.6 (the one at /usr/lib).

try this

export LD_LIBRARY_PATH=/usr/local/lib
ldd ./app

and then execute you program

ldd ./app returns
linux-gate.so.1 => (0xffffe000)
libfcgi++.so.0 => /usr/local/lib/libfcgi++.so.0 (0x40001000)
libsqlite3.so.0 => /usr/local/lib/libsqlite3.so.0 (0x40006000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x46dfb000)
libm.so.6 => /lib/libm.so.6 (0x46dab000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x46ded000)
libc.so.6 => /lib/libc.so.6 (0x46c69000)
libfcgi.so.0 => /usr/local/lib/libfcgi.so.0 (0x40077000)
libnsl.so.1 => /lib/libnsl.so.1 (0x46543000)
libpthread.so.0 => /lib/libpthread.so.0 (0x46dd4000)
/lib/ld-linux.so.2 (0x4629a000)
./app does not crash as before
but when I run it from the webrowser (this is a fastcgi app) the apache error_logs contains the following line:
[Fri Dec 28 14:14:25 2007] [error] [client 99.xxxx] ...cgi-bin/app: symbol lookup error: ...cgi-bin/app: undefined symbol: sqlite3_open_v2
[Fri Dec 28 14:14:25 2007] [error] [client 99.xxxx] Premature end of script headers: app.

add

-Wl,-R/usr/local/lib

to your Makefile and rebuild.

then rerun as a cgi

Hello,
When I use the sqlite3_open function, there is no issue but with sqlite3_open_v2, compilation completes fine but at run-time as a cgi I am getting:
[warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Fri Dec 28 22:58:46 2007] [error] [client 99xxx] Premature end of script headers: app
At least it's working and I will explore the v2-related issues a bit later.
Thank you for your help