>>>>> "JH" == J Heffner <jheffner@stripped> writes:
JH> Sorry- there was a typo in my orginal command line. I had, in fact, been
JH> using -lmysqlclient rather than -llibmysqlclient. After wrestling with
JH> this a bit more, I decided to see if changing the order would help - and
JH> it solved the problem. I now use the following command line:
JH> g++ -o filename -I./include filename.cc database.cc -L/usr/lib/mysql -lmysqlclient
JH> One works, one doesn't. Weird.
No, it is not wierd once you consider the semantics of your command.
All commands to the C or C++ compiler are interpreted in the order
given, left to right. Specifiying a file name means to compile it and
keep track of its external object reference. The -o specifies the
output file for the link phase, which happens last. The -L tells the
link phase that for any subsequent -l arguments, search this path.
The -l argument says to scan this library for any currently undefined
If you specify a -l library *before* any code references anything from
it, then nothing will get pulled from that library.
This has been covered in this mailing list several times before.
>> Try this:
>> g++ -o filename -I./include -L/usr/lib/mysql -lmysqlclient filename.cc
For the reasons cited above, this is not guaranteed to work, since
there are no undefined symbols that the linker will look for when it
gets to libmysqlclient.a.
It may differ for Linux shared libs, but that is an implementation
detail which is non-portable.
Vivek Khera, Ph.D. Khera Communications, Inc.
Internet: khera@stripped Rockville, MD +1-301-545-6996
PGP & MIME spoken here http://www.kciLink.com/home/khera/