mysql++ Problem beim Kompilieren
-
Hallo zusammen,
ich wollte mich endlich mal an c++ mit mysql ranwagen, habe da aber noch nen kleines Problem.
mysql++ und libmysqlclient14-dev sind soweit installiert.Ich wollte jetzt die simple1.cpp mal testweise kompilieren in der folgendes steht:
#include "cmdline.h" #include "printdata.h" #include <mysql++.h> #include <iostream> #include <iomanip> using namespace std; using namespace mysqlpp; int main(int argc, char *argv[]) { // 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, server, user, pass)) { // Retrieve a subset of the sample stock table set up by resetdb // and display it. mysqlpp::Query query = conn.query("select item from stock"); if (mysqlpp::StoreQueryResult res = query.store()) { cout << "We have:" << endl; for (size_t i = 0; i < res.num_rows(); ++i) { cout << '\t' << res[i][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; } }
Ich bekomme folgenden netten Fehler, mit dem ich nichts anfangen kann.
/tmp/cczpOcNv.o(.text+0x62): In function
main': : undefined reference to
parse_command_line(int, char**, char const**, char const**, char const**, char const**, char const*)'
collect2: ld returned 1 exit statusKompilieren wollte ich mit:
g++ simple1.cpp -L/usr/local/lib/mysql++ -lmysqlpp -L/usr/lib/mysql -lmysqlclient -I/usr/local/include/mysql++ -I/usr/include/mysql
Jemand eine Idee?
Viele Grüße,
Kai
-
deine methode parse_command_line() gibts nicht. wahrscheinlich brauchst du noch eine zusätzliche source-file.
-
Ahh cool, stimmt.
Ich habe die werte einfach mal fix gesetzt und die betreffenden zeilen auskommentiert.
Klappt jetzt.
Danke!
Grüße
Kai