1.Èí¼þ»·¾³ubuntu10.10
2. °²×°mysql -- sudo apt-get install mysqlserver
3. °²×° libmysqlclient15-dev -- sudo apt-get install libmysqlclient15-dev
£¨Èç¹ûÌáʾûÓа²×°°ü£¬¿ÉÒÔÓÃsudo apt-get install updateºÍsudo apt-get install upgrade½øÐиüкÍÉý¼¶£¬Èç¹ûûÓÐÍøÂç¿´À´ºÜÄÑѧϰubuntu£©
4 ÏÂÔØmysql++ --
http://tangentsoft.net/mysql++/releases/mysql++-3.0.9.tar.gz
5 tar -vxf mysql++-3.0.9.tar.gz
6 cd mysql++-3.0.9
7. ./configure --prefix=/usr
8. make µÚÒ»´Î¿ÉÄÜʧ°Ü£¬»áÌáʾ£º./lib/refcounted.h:258:2: ´íÎó£º ¡®size_t¡¯²»ÊÇÒ»¸öÀàÐÍÃû
./lib/refcounted.h: ÔÚ¹¹Ô캯Êý¡®mysqlpp::RefCountedPointer
½â¾ö·½·¨£º´ò¿ª./lib/refcounted.h£¬Ìí¼Ó#include
9.ÖØбàÒëmake
10. sudo make install
11. °²×°Íê±Ï¡£
12 ²âÊÔ ´úÂë
#include
#include
#include
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 = "";
db = "school";
server = "127.0.0.1";
user = "root";
pass = "hlf";
// 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 * from student");
if (mysqlpp::StoreQueryResult res = query.store()) {
cout << "We have:" << endl;
mysqlpp::StoreQueryResult::const_iterator it;
for (it = res.begin(); it != res.end(); ++it) {
mysqlpp::Row row = *it;
cout << '\t' << row[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;
}
}
13 makefile
tsql:tsql.cpp
g++ -o tsql tsql.cpp -I/usr/include/mysql -I/usr/include/mysql++ -L/usr/lib -lmysqlpp
×¢Ò⣬һ¶¨ÒªÓÐlmysqlpp£¬¸Ã¾äÊÇΪÁËʹÓÿâlibmysqlpp.a
kaka_425644 ÓÚ 2012-01-20 10:53:58·¢±í:
¶¥
Askanswer ÓÚ 2012-01-19 19:42:10·¢±í:
Ö§³ÖÒ»¸ö¡£
ÃÔÄã°ævcxz ÓÚ 2012-01-18 15:33:03·¢±í:
¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥
GrowthÕ× ÓÚ 2012-01-18 10:03:41·¢±í:
¸ÐлhaolifengwangµÄ·ÖÏí£¬±¾Ìù¼ÓÈëµ½ÂÛ̳¶¥ÖõÄLinuxÓ¦ÓÃÌùÖÐ
onquer ÓÚ 2012-01-17 10:24:00·¢±í:
Ö§³Ö