List:MySQL++« Previous MessageNext Message »
From:news Date:March 27 2008 4:50pm
Subject:Compiling Troubles
View as plain text  
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/html/userman/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

Thread
Compiling Troublesnews27 Mar
  • Re: Compiling TroublesWarren Young27 Mar
    • Re: Compiling Troublesnews27 Mar
      • Re: Compiling TroublesWarren Young27 Mar