Всё крутиться на freeBSD 7.0. Компилирую программу следующим образом:
# g++ -I/usr/local/include/mysql -I/usr/include/mysql++ -L/usr/local/lib/mysql -lmysqlclient -lmysqlpp -o testsql testsql.cpp
Но при компиляции получаю вот эту пачку ошибок и не знаю что дальше делать :
Код | /var/tmp//ccDLj8H5.o(.text+0x28f): In function `main': : undefined reference to `mysqlpp::Connection::connect(char const*, char const*, char const*, char const*, unsigned int)' /var/tmp//ccDLj8H5.o(.text+0x2b4): In function `main': : undefined reference to `mysqlpp::Connection::query(char const*)' /var/tmp//ccDLj8H5.o(.text+0x366): In function `main': : undefined reference to `mysqlpp::operator<<(std::ostream&, mysqlpp::String const&)' /var/tmp//ccDLj8H5.o(.text+0x3a9): In function `main': : undefined reference to `mysqlpp::Query::error() const' /var/tmp//ccDLj8H5.o(.text+0x477): In function `main': : undefined reference to `mysqlpp::Connection::error() const' /var/tmp//ccDLj8H5.o(.gnu.linkonce.t._ZN7mysqlpp5Query5storeEv+0x42): In function `mysqlpp::Query::store()': : undefined reference to `mysqlpp::SQLTypeAdapter::SQLTypeAdapter(std::string const&, bool)' /var/tmp//ccDLj8H5.o(.gnu.linkonce.t._ZN7mysqlpp5Query5storeEv+0x5b): In function `mysqlpp::Query::store()': : undefined reference to `mysqlpp::Query::store(mysqlpp::SQLTypeAdapter const&)'
|
На сколько мне понятно , то он не может найти mysqlpp , хотя он прописан в ldconfig-e и я его указываю при компиляции -lmysqlpp.
Собственно код самой программы :
Код | #include <mysql++.h>
#include <iostream> #include <iomanip>
using namespace std;
int main(int argc, char *argv[]) { // Get database access parameters from command line const char* db = 0, *server = 0, *user = 0, *pass = "";
// 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; } }
|
Помогите пожалуйсто , в чём может быть проблема тут ? |