The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using funcion in a shared library yhacks High Level Programming 1 05-23-2008 04:03 AM
Shared memory in shared library DreamWarrior High Level Programming 12 05-30-2007 01:33 PM
shared library areef4u UNIX for Advanced & Expert Users 1 07-31-2006 11:14 PM
Creation of Shared library sarangb SCO 0 06-17-2005 04:51 AM
Shared Library rajashekaran High Level Programming 2 08-03-2002 10:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-28-2007
JCR JCR is offline
Registered User
 

Join Date: Jan 2007
Posts: 29
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
Reply With Quote
Forum Sponsor
  #2  
Old 12-28-2007
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
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 ...
Reply With Quote
  #3  
Old 12-28-2007
JCR JCR is offline
Registered User
 

Join Date: Jan 2007
Posts: 29
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
Reply With Quote
  #4  
Old 12-28-2007
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Quote:
Originally Posted by JCR View Post
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
Reply With Quote
  #5  
Old 12-28-2007
JCR JCR is offline
Registered User
 

Join Date: Jan 2007
Posts: 29
$(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.
Reply With Quote
  #6  
Old 12-28-2007
Registered User
 

Join Date: Dec 2007
Posts: 255
post the output of the below commands

Code:
ldd ./app
echo $LD_LIBRARY_PATH
Reply With Quote
  #7  
Old 12-28-2007
JCR JCR is offline
Registered User
 

Join Date: Jan 2007
Posts: 29
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0