shared library not found


 
Thread Tools Search this Thread
Top Forums Programming shared library not found
# 1  
Old 12-28-2007
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
# 2  
Old 12-28-2007
Code:
$(CPP) -LLIBDIR $(FASTCGI_LIB) $(SQLITE_LIB) -o $(TARGET_APP) main.o

How about changing the line above to this one
Code:
$(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 ...
# 3  
Old 12-28-2007
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
# 4  
Old 12-28-2007
Quote:
Originally Posted by JCR
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
Code:
$(CPP) -L $(FASTCGI_LIB) -L /usr/local/lib/ -lsqlite3 -o $(TARGET_APP) main.o

# 5  
Old 12-28-2007
$(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.
# 6  
Old 12-28-2007
post the output of the below commands

Code:
ldd ./app
echo $LD_LIBRARY_PATH

# 7  
Old 12-28-2007
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Shared-library error

Hi All, i am facing shared library error, below is the output of the command I am executing on my client # /usr/software/bin/sudo /usr/software/bin/sudo: error while loading shared libraries: libaudit.so.1: cannot open shared object file: No such file or directory # I tried install... (4 Replies)
Discussion started by: muzaffar.k
4 Replies

2. AIX

Add shared members from library to same library in a different directory

I'm trying to install libiconv to AIX 7.1 from an rpm off of the perzl site. The rpm appears to install but I get this error message. add shr4.o shared members from /usr/lib/libiconv.a to /opt/freeware/lib/libiconv.a add shr.o shared members from /usr/lib/libiconv.a to ... (5 Replies)
Discussion started by: kneemoe
5 Replies

3. Programming

Shared library with acces to shared memory.

Hello. I am new to this forum and I would like to ask for advice about low level POSIX programming. I have to implement a POSIX compliant C shared library. A file will have some variables and the shared library will have some functions which need those variables. There is one special... (5 Replies)
Discussion started by: iamjag
5 Replies

4. Programming

Makefile shared library g++

I'm having trouble with my makefile, I'm trying to code a shared library to be used by another program *EDIT* Found the solution: CC = g++ MODULES= readconfig.o ReadConfigLib.o OBJECTS= RCLOBJECTS= ReadConfigLib.cpp readconfig.cpp configDefinitions.h readconfig.h ReadConfigLib.h... (0 Replies)
Discussion started by: james2432
0 Replies

5. Shell Programming and Scripting

How to change a Makefile from building static library to shared library?

Hi: I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library) Thanks. (1 Reply)
Discussion started by: cpthk
1 Replies

6. Programming

Shared memory for shared library

I am writing a shared library in Linux (but compatible with other UNIXes) and I want to allow multiple instances to share a piece of memory -- 1 byte is enough. What's the "best" way to do this? I want to optimize for speed and portability. Obviously, I'll have to worry about mutual exclusion. (0 Replies)
Discussion started by: otheus
0 Replies

7. Programming

Shared memory in shared library

I need to create a shared library to access an in memory DB. The DB is not huge, but big enough to make it cumbersome to carry around in every single process using the shared library. Luckily, it is pretty static information, so I don't need to worry much about synchronizing the data between... (12 Replies)
Discussion started by: DreamWarrior
12 Replies

8. UNIX for Advanced & Expert Users

shared library

What is the primary difference between static library and dynamic library? and how to write static shared library? (1 Reply)
Discussion started by: areef4u
1 Replies

9. SCO

Creation of Shared library

Hi all, I am new to sco unix. I would like to know abt the procedure to create shared library in Sco-unix. Is it differ from linux? any help?? Thanx in Advance!!!!! (0 Replies)
Discussion started by: sarangb
0 Replies

10. Programming

Shared Library

hello all I want to work in shared libraries how can i work in Linux Environment ? (2 Replies)
Discussion started by: rajashekaran
2 Replies
Login or Register to Ask a Question