[odb-users] RE: Linux Linking ODB - libtool vs g++
Szumowski, Thomas
thomas.szumowski at lmco.com
Mon Aug 29 12:47:05 EDT 2011
Looks like my third strike today. :)
I noticed the main difference between the libtool and g++ calls were libtools inclusion of "-Wl,-rpath,/usr/local/lib". Adding that to g++ and naturally it works fine. So perhaps I just need to ensure I have that added in as needed?
-Tom
-----Original Message-----
From: odb-users-bounces at codesynthesis.com [mailto:odb-users-bounces at codesynthesis.com] On Behalf Of Szumowski, Thomas
Sent: Monday, August 29, 2011 12:24 PM
To: odb-users at codesynthesis.com
Subject: EXTERNAL: [odb-users] Linux Linking ODB - libtool vs g++
I was following the example in the ODB user manual section 2.3 "Compiling and Running". I am on a linux machine. I noticed when I get to the point of running the equivalent command "c++ -o driver driver.o person-odb.o -lodb-mysql -lodb", I get an error. But when I run the make in the examples (hello), it runs libtool and I get no errors. See below for my results. First I link using libtool, as done in the makefile. That works fine and I can execute the program. But then I try the line in the user manual and it fails. Any recommendations? And should I just always use libtool to build?
-----------------------------------
OUTPUT
-----------------------------------
[user at localhost tmp]$ ../../libtool --tag=CXX --mode=link g++ -g -O2 -o driver driver.o person-odb.o -lodb-sqlite -lodb -lpthread
libtool: link: g++ -g -O2 -o driver driver.o person-odb.o /usr/local/lib/libodb-sqlite.so /usr/local/lib/libodb.so -lpthread -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib
[user at localhost tmp]$ ls
database.hxx driver driver.cxx driver.o person.hxx person-odb.cxx person-odb.hxx person-odb.ixx person-odb.o
[user at localhost tmp]$ ./driver
Hello, John Doe!
Hello, Jane Doe!
[user at localhost tmp]$ g++ -o driver driver.o person-odb.o -lodb-sqlite -lodb
/usr/local/lib/libodb-sqlite.so: undefined reference to `sqlite3_open_v2'
/usr/local/lib/libodb-sqlite.so: undefined reference to `sqlite3_extended_errcode'
/usr/local/lib/libodb-sqlite.so: undefined reference to `sqlite3_prepare_v2'
collect2: ld returned 1 exit status
-----------------------------------
-Tom
More information about the odb-users
mailing list