Undefined Reference
Posted by: Ryan Jackson
Date: January 30, 2011 01:10PM

I am definitely new to this, and this does not seem to be a new issue people struggle with. Below is my code and following that is the command I ran.

########################## CODE ################################

//#include "cmdline.h"
//#include "printdata.h"

//#include "mysql++/mysql++.h"
#include <mysql++.h>

#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[])
{
cout << "testing2" << endl;


// Get database access parameters from command line
//const char* db = 0, *server = 0, *user = 0, *pass = "";
//if (!parse_command_line(argc, argv, &db, &server, &user, &pass)) {
//return 1;
//}

// Connect to the sample database.
mysqlpp::Connection conn(false);
if (conn.connect("DB", "HOST", "USER", "PASS")) {

mysqlpp::Query query = conn.query("select * from `commands`");
if (mysqlpp::StoreQueryResult res = query.store()) {
cout << "We have:" << endl;
for (size_t i = 0; i < res.num_rows(); ++i) {
cout << '\t' << res[0] << endl;
}
}
else {
cerr << "Failed to get item list: " << query.error() << endl;
return 1;
}

return 0;
}
else {
cerr << "DB connection failed: " << conn.error() << endl;
return 1;
}

return 0;
}

########################### Command ################################

g++ -I/usr/local/include/mysql++ -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lmysqlpp -lm -lz simpletest.cpp


I have tried a lot of different combinations of the include and library paths, but I still get the following error:

############################ Error ##################################

/tmp/cc5L9oyd.o: In function `main':
simpletest.cpp:(.text+0xe7): undefined reference to `mysqlpp::Query::store()'
/tmp/cc5L9oyd.o: In function `mysqlpp::Row::operator[](int) const':
simpletest.cpp:(.text._ZNK7mysqlpp3RowixEi[mysqlpp::Row::operator[](int) const]+0x1a): undefined reference to `mysqlpp::Row::at(unsigned long) const'
collect2: ld returned 1 exit status



Thanks for your help in advance!

Options: ReplyQuote


Subject
Views
Written By
Posted
Undefined Reference
1043
January 30, 2011 01:10PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.