dbTalk Databases Forums  

Compiling Troubles

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Compiling Troubles in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
news@dmcdonald.net
 
Posts: n/a

Default Compiling Troubles - 03-27-2008 , 10:50 AM






It's been a while since ive used mysql++, last time was just after Warren
released a couple of new version after taking the reigns, so thought
prehaps id come back and take another look. Had a quick look through the
tutorial http://tangentsoft.net/mysql++/doc/h.../tutorial.html and
built a quick example application. As far as I can see, I don't see why
this isnt compiling. In perticular, im clueless as to how gcc figures
these two...

main.cpp:24: error: 'StoreQueryResult' is not a member of 'mysqlpp'
main.cpp:23: error: no matching function for call to
'mysqlpp::Connection::query(const char [19])'

Which makes me think its somekind of problem where im not including the
right header files, but the following code compiles, links, and runs as
expected.

#include <mysql++.h>

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
string password;
cin >> password;

mysqlpp::Connection conn(false);
if( conn.connect( "database", "localhost", "user",
password.c_str()) ) {
cout << "Connected to localhost" << endl;
}
else {
cout << "Connection Failed" << endl;
return 1;
}
return 0;
}

But my slightly more advanced code wont. So the other thing im thinking is
that prehaps im using an old/new version which doesnt have the same
objects/overloaded methods. But I can't find any mention of a version in
mysql++.h except this

// Encode MySQL++ library version number. MYSQLPP_VERSION macro takes
// like 0x010203. MYSQLPP_LIB_VERSION is the current library version
// conditional code based on the MySQL++ library version.

cout << MYSQLPP_LIB_VERSION << endl;

This code produces
131078

I used apt-get on an ubuntu install to install mysqlpp, and there was no
mention of a version on the package which I could see.

Heres the full gcc command, errors, and source file.

$ g++ main.cpp -o exec -I/usr/include/mysql++/ -I/usr/include/mysql -lmysqlpp
main.cpp: In function 'int main(int, char**)':
main.cpp:23: error: no matching function for call to
'mysqlpp::Connection::query(const char [19])'
/usr/include/mysql++/connection.h:199: note: candidates are:
mysqlpp::Query mysqlpp::Connection::query()
main.cpp:24: error: 'StoreQueryResult' is not a member of 'mysqlpp'
main.cpp:24: error: expected `;' before 'res'
main.cpp:26: error: 'res' was not declared in this scope

main.cpp

#include <mysql++.h>

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
string password;
cin >> password;

mysqlpp::Connection conn(false);
if( conn.connect( "database", "localhost", "user",
password.c_str()) ) {
cout << "Connected to localhost" << endl;
}
else {
cout << "Connection Failed" << endl;
return 1;
}

mysqlpp::Query query = conn.query("select * from test");
mysqlpp::StoreQueryResult res = query.store();

if( res ) {
for( int i = 0; i < res.num_rows(); i++ ) {
cout << res[i][0] << ", " << res[i][1] << ", " <<
res[i][2] << endl;
}
}
else {
cout << "Failed to execure query" << endl;
return 1;
}

return 0;
}

**EOF**

Any help would be appricated.

Thanks,

Renski


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Compiling Troubles - 03-27-2008 , 11:08 AM






news (AT) dmcdonald (DOT) net wrote:
Quote:
// Encode MySQL++ library version number. MYSQLPP_VERSION macro takes
// like 0x010203. MYSQLPP_LIB_VERSION is the current library version
// conditional code based on the MySQL++ library version.

cout << MYSQLPP_LIB_VERSION << endl;

This code produces
131078
That's version 2.0.6. (It's easier to read in hex: 0x020006.)

This agrees with your other symptoms, which is that v3 constructs aren't
compiling against these old headers.

Quote:
I used apt-get on an ubuntu install to install mysqlpp,
So the old headers are probably in /usr/local/include, and the new ones
in /usr/include. You need to clean the old stuff out of the way somehow
so the compiler and linker can find the new stuff.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
news@dmcdonald.net
 
Posts: n/a

Default Re: Compiling Troubles - 03-27-2008 , 11:33 AM



Serves me right for being lazy and not compiling from sources I suppose.

did an apt-get remove on the libs and then compiled from source. However..

$ ./exec
../exec: error while loading shared libraries: libmysqlpp.so.3: cannot open
shared object file: No such file or directory

but this was fixed with

$ su
Password:
# cp /usr/local/lib/libmysqlpp.so.3 /usr/lib/
# ./exec
[password was here]
Connected to localhost
1, Red Ball, 2.99
2, Blue Ball, 1.99
3, Green Ball, 0.99
#

So all working now, Thanks Warren.

Renski

Quote:
news (AT) dmcdonald (DOT) net wrote:

// Encode MySQL++ library version number. MYSQLPP_VERSION macro takes
// like 0x010203. MYSQLPP_LIB_VERSION is the current library version
// conditional code based on the MySQL++ library version.

cout << MYSQLPP_LIB_VERSION << endl;

This code produces
131078

That's version 2.0.6. (It's easier to read in hex: 0x020006.)

This agrees with your other symptoms, which is that v3 constructs aren't
compiling against these old headers.

I used apt-get on an ubuntu install to install mysqlpp,

So the old headers are probably in /usr/local/include, and the new ones
in /usr/include. You need to clean the old stuff out of the way somehow
so the compiler and linker can find the new stuff.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsu...nald (DOT) net




--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: Compiling Troubles - 03-27-2008 , 11:51 AM



news (AT) dmcdonald (DOT) net wrote:
Quote:
# cp /usr/local/lib/libmysqlpp.so.3 /usr/lib/
You just need to add /usr/local/lib to /etc/ld.so.conf Linux's ldd will
only look in directories listed there, and /usr/local/lib isn't there by
default in most distros.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.