не компилируется mysql++ поставлена из deb пакета, ос убунту 8 10 (х64) при компиляции выдает следующее Код | /tmp/ccvZHTPU.o: In function `main': simple1.cpp:(.text+0xc3): undefined reference to `parse_command_line(int, char**, char const**, char const**, char const**, char const**, char const*)' simple1.cpp:(.text+0xe7): undefined reference to `mysqlpp::Connection::Connection(bool)' simple1.cpp:(.text+0x109): undefined reference to `mysqlpp::Connection::connect(char const*, char const*, char const*, char const*, unsigned int)' simple1.cpp:(.text+0x126): undefined reference to `mysqlpp::Connection::query(char const*)' simple1.cpp:(.text+0x1c0): undefined reference to `mysqlpp::operator<<(std::basic_ostream<char, std::char_traits<char> >&, mysqlpp::String const&)' simple1.cpp:(.text+0x204): undefined reference to `mysqlpp::Query::error() const' simple1.cpp:(.text+0x2fd): undefined reference to `mysqlpp::Connection::error() const' simple1.cpp:(.text+0x360): undefined reference to `mysqlpp::Connection::~Connection()' simple1.cpp:(.text+0x37f): undefined reference to `mysqlpp::Connection::~Connection()' /tmp/ccvZHTPU.o: In function `mysqlpp::Query::store()': simple1.cpp:(.text._ZN7mysqlpp5Query5storeEv[mysqlpp::Query::store()]+0x2c): undefined reference to `mysqlpp::Query::str(mysqlpp::SQLQueryParms&)' simple1.cpp:(.text._ZN7mysqlpp5Query5storeEv[mysqlpp::Query::store()]+0x3e): undefined reference to `mysqlpp::SQLTypeAdapter::SQLTypeAdapter(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)' simple1.cpp:(.text._ZN7mysqlpp5Query5storeEv[mysqlpp::Query::store()]+0x4f): undefined reference to `mysqlpp::Query::store(mysqlpp::SQLTypeAdapter const&)' collect2: выполнение ld завершилось с кодом возврата 1
|
компилю так Код | mysql++-3.0.6/examples$ g++ simple1.cpp -o test -I/usr/include/mysql -I/usr/include/mysql++ -L/usr/include/mysql -lmysqlclient
|
код примера Код | #include "cmdline.h" #include "printdata.h"
#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 = ""; 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; } }
|
Это сообщение отредактировал(а) americanets - 6.11.2008, 11:35
--------------------
Пусть популярную музыку слушают те, среди кого она популярна
|