5 messages in com.mysql.lists.plusplusRe: zlib and mysql++ build process| From | Sent On | Attachments |
|---|---|---|
| Dennis McFall | 28 Mar 2005 11:35 | |
| Chris Frey | 28 Mar 2005 12:22 | |
| Dennis McFall | 28 Mar 2005 13:54 | |
| Ed Terchunian | 28 Mar 2005 20:19 | |
| Warren Young | 29 Mar 2005 04:56 |
| Subject: | Re: zlib and mysql++ build process![]() |
|---|---|
| From: | Ed Terchunian (eter...@haverford.edu) |
| Date: | 03/28/2005 08:19:48 PM |
| List: | com.mysql.lists.plusplus |
You might want to tack a -lmysqlpp onto that compilation, i.e.
g++ -o dbtest dbtest.cpp -lmysqlpp
It won't link the library unless you tell it to.
In the future you should probably refer to the example programs provided with the package, they seem to answer all of my questions.
Ed Terchunian
Dennis McFall wrote:
After installing the Fedora Core 2 zlib dev package I was able to successfully compile mysql++.
I still went ahead and added the two new path entries to the ld.so.conf file and executed ldconfig.
Encouraged, I tried to compile my dbtest.cpp test program but still encountered many errors. I have not been able to determine what is going on even though I have tried for most of the day. Unfortunately, in this case, my forte` is windows development and not linux development. I may have screwed something up (versioning etc) while I was trying to staisfy all the rpm dependencies. This machine was not originally setup for development so I had to load gcc and everything it depended on.
I am simply trying to use some of the sample code to connect to my local database and execute a select query. The code is below:
#include <iostream> #include <iomanip> #include <mysql++.h>
using namespace mysqlpp; using namespace std;
int main() { Connection con("test","localhost","test","test"); // The full format for the Connection constructor is // Connection(cchar *db, cchar *host="", // cchar *user="", cchar *passwd="") // You may need to specify some of them if the database is not on // the local machine or you database username is not the same as your // login name, etc..
Query query = con.query(); // This creates a query object that is bound to con.
query << "SELECT * FROM monitor"; // You can write to the query object like you would any other ostrem
Result res = query.store(); // Query::store() executes the query and returns the results
cout << "Query: " << query.preview() << endl; // Query::preview() simply returns a string with the current query // string in it.
cout << "Records Found: " << res.size() << endl << endl;
Row row; cout.setf(ios::left); cout << setw(10) << "monitor_id" << setw(1) << "monitor_type" << setw(50) << "monitor_title" << setw(4) << "monitor_status" << setw(4) << "monitor_email" << setw(10) << "monitor_day_ttl" << setw(10) << "monitor_week_ttl" << setw(10) << "monitor_month_ttl" << endl;
Result::iterator i; // The Result class has a read-only Random Access Iterator for (i = res.begin(); i != res.end(); i++) { row = *i; cout << setw(10) << row["monitor_id"] << setw(10) << row["monitor_type"] << setw(50) << row["monitor_title"] << setw(4) << row["monitor_status"] << setw(4) << row["monitor_email"] << setw(10) << row["monitor_day_ttl"] << setw(10) << row["monitor_week_ttl"] << setw(10) << row["monitor_month_ttl"] << endl; } return 0; }
The errors I am getting are shown below:
[root@localhost temp]# g++ -o dbtest dbtest.cpp /tmp/ccIwAWIf.o(.text+0x35): In function `main': : undefined reference to `mysqlpp::Connection::Connection[in-charge](char const*, char const*, char const*, char const*, bool)' /tmp/ccIwAWIf.o(.text+0x4e): In function `main': : undefined reference to `mysqlpp::Connection::query()' /tmp/ccIwAWIf.o(.text+0x700): In function `main': : undefined reference to `mysqlpp::Connection::~Connection [in-charge]()' /tmp/ccIwAWIf.o(.text+0x79f): In function `main': : undefined reference to `mysqlpp::Connection::~Connection [in-charge]()' /tmp/ccIwAWIf.o(.gnu.linkonce.t._ZN7mysqlpp3RowC1Ev+0x2c): In function `mysqlpp::Row::Row[in-charge]()': : undefined reference to `vtable for mysqlpp::Row' /tmp/ccIwAWIf.o(.gnu.linkonce.t._ZN7mysqlpp3RowC1Ev+0x38): In function `mysqlpp::Row::Row[in-charge]()': : undefined reference to `vtable for mysqlpp::Row' /tmp/ccIwAWIf.o(.gnu.linkonce.t._ZN7mysqlpp3RowD1Ev+0xc): In function `mysqlpp::Row::~Row [in-charge]()': : undefined reference to `vtable for mysqlpp::Row' /tmp/ccIwAWIf.o(.gnu.linkonce.t._ZN7mysqlpp3RowD1Ev+0x18): In function `mysqlpp::Row::~Row [in-charge]()': : undefined reference to `vtable for mysqlpp::Row' /tmp/ccIwAWIf.o(.gnu.linkonce.t._ZN7mysqlpp6ResultD1Ev+0x1a): In function `mysqlpp::Result::~Result [in-charge]()': : undefined reference to `mysqlpp::ResUse::~ResUse [not-in-charge]()' /tmp/ccIwAWIf.o(.gnu.linkonce.t._ZN7mysqlpp5Query7previewEv+0x1b): In function `mysqlpp::Query::preview()': : undefined reference to `mysqlpp::SQLQuery::str(mysqlpp::SQLQueryParms&)'
I believe mysql++ will be perfect for what I am trying to do so any assistance getting this code up and running would really be appreciated.
----- Original Message ----- From: "Mike Kinney" <kinn...@redacesolutions.com> To: "Dennis McFall" <denn...@interclay.com> Sent: Monday, March 28, 2005 2:35 PM Subject: Re: zlib and mysql++ build process
If you're using the zlib from Fedora, then make sure /usr/local/lib and /usr/lib are in /etc/ld.so.conf file (and run "ldconfig"!)
It *looks* like you need to do "-lzlib" not "-lz".
For what it's worth, I think you *can* migrate up to the 4.xx series, but simply have to put in that stinkin' "old_passwords=1" in your /etc/my.cnf file.
Hope that helps!
On Mon, 2005-03-28 at 13:35 -0600, Dennis McFall wrote:
I am attempting to build mysql++ on a Fedora Core 2 machine. The
following rpms have been installed:
mysql++-1.7.32-1 mysql-devel-3.23.58-9 mysql-3.23.58-9 mysql-server-3.23.58-9 php-mysql-4.3.4-11 mysql++-devel-1.7.32-1 MySQL-shared-3.23.58-1
I have to stay with MYSQL version 3.23.58 due to the existing
installbase.
The configure.h file that is generated states that I do not have support
for zlib, however, I do, as the "rpm -qa" shows below.
rpm -qa | grep zlib* zlib-1.2.1.1-2.1
The make process fails to complete because ld can't find -lz.
/usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status make[2]: *** [libmysqlpp.la] Error 1 make[2]: Leaving directory `/home/insite/temp/mysql++-1.7.32/lib' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/insite/temp/mysql++-1.7.32' make: *** [all] Error 2
I attempted to show "configure" where the zlib.h file is by adding an
"--includedir" option but this did not help.
./configure '--includedir=/usr/local/include/mysql++'
'--includedir=/lib/modules/2.6.5-1.358/build/include/linux/' --enable-thread -check
Any suggestions?
-- Mike Kinney www.RedAceSolutions.com Phone (503) 590-5606 x201




