automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Buliding a shared library and need to specify an existing library, h


From: Jim Lynch
Subject: Re: Buliding a shared library and need to specify an existing library, how?
Date: Thu, 29 Jun 2006 13:19:18 -0400
User-agent: Thunderbird 1.5.0.4 (X11/20060516)

Ralf Wildenhues wrote:
Hello Jim,

* Jim wrote on Wed, Jun 28, 2006 at 09:50:53PM CEST:
Note you list -lsqlite3 both before and after -limageserver-0.1.
Try listing it after only (or do they depend on each other mutually?
Then you may need --preserve-dup-deps in AM_LIBTOOLFLAGS).  But...
I tried it before, after and both.  Nothing changed.
Here's the error:
g++ -g -O2 -o vaprobe arc.o probethread.o protocamera.o protosimple.o vaprobe.o -L/usr/lib/mysql -limageserver-0.1 /usr/lib/libsqlite3.so -lmysqlpp -lboost_regex /usr/lib/libmysqlclient.so -lpthread -lssl -lccgnu2 /usr/lib/libcurl.so -lccext2 -ldl /usr/lib/libxml2.so /usr/local/lib/libimageserver-0.1.so: undefined reference to `sqlite3_decode_binary(unsigned char const*, unsigned char*)'

...is sqlite3_decode_binary a function with C or C++ linkage?  The above
error does not find a C++ linkage function, maybe that was the real
problem.  Also, on my system, the /usr/lib/libsqlite3.so.0 from Debian
package libsqlite3-0 3.2.1-1 apparently does not contain a function of
this name at all, neither C nor C++ linkage.
I am using a c++ wrapper to provide sqlite3 classes. The code inside of one of the C++ files includes:
////////////////////////////////////////////////////////////////////////////////
// Prototypes for SQLite functions not included in SQLite DLL, but copied below
// from SQLite encode.c
////////////////////////////////////////////////////////////////////////////////
int sqlite3_encode_binary(const unsigned char *in, int n, unsigned char *out);
int sqlite3_decode_binary(const unsigned char *in, unsigned char *out);

Apparently these are undocumented functions. I don't know how to list objects in a share object library so I can't say for sure that those two are there. I do know if I take the c++ classes and compile them with the application, vaprobe, create .o files and link them in, that it loads without errors. I'm guessing somehow in the loading process ld or whoever forgot that sqlite3_encode_binary was there. I was hoping there was something I could do when I generated the library to say "I'm going to need libsqlite3.so when you start using this library" but I guess that was too much to ask for.

This is very interesting. I didn't show you all of the output and I missed this the first time.

/bin/sh ../libtool --tag=CXX --mode=link g++ -g -O2 -o vaprobe arc.o probethread.o protocamera.o protosimple.o vaprobe.o -L/usr/lib/mysql -lsqlite3 -limageserver-0.1 -lsqlite3 -lmysqlpp -lboost_regex -lmysqlclient -lpthread -lssl -lccgnu2 -lcurl -lccext2 -ldl -lxml2

g++ -g -O2 -o vaprobe arc.o probethread.o protocamera.o protosimple.o vaprobe.o -L/usr/lib/mysql -limageserver-0.1 /usr/lib/libsqlite3.so -lmysqlpp -lboost_regex /usr/lib/libmysqlclient.so -lpthread -lssl -lccgnu2 /usr/lib/libcurl.so -lccext2 -ldl /usr/lib/libxml2.so

/usr/local/lib/libimageserver-0.1.so: undefined reference to `sqlite3_decode_binary(unsigned char const*, unsigned char*)' /usr/local/lib/libimageserver-0.1.so: undefined reference to `sqlite3_encode_binary(unsigned char const*, int, unsigned char*)'
collect2: ld returned 1 exit status

Note that the libtool command line included my library list verbatim. However the line he generated only had the sqlite3 library following my library.

Now if I add the .o file for the wrapper to the list, it works fine:

g++ -g -O2 -o vaprobe -lsqlite3 arc.o probethread.o protocamera.o protosimple.o vaprobe.o -L/usr/lib/mysql -limageserver-0.1 /usr/lib/libsqlite3.so -lmysqlpp -lboost_regex /usr/lib/libmysqlclient.so -lpthread -lssl -lccgnu2 /usr/lib/libcurl.so -lccext2 -ldl /usr/lib/libxml2.so -lsqlite3 /tmp/CppSQLite3.o

HOWEVER if I add the same definitions to my main class that CppSQLite3 has and generate calls to them, it still fails to find them. I don't know what the magic is here.

Hope this helps.

Cheers,
Ralf


Thanks, Jim.








reply via email to

[Prev in Thread] Current Thread [Next in Thread]