ºìÁªLinuxÃÅ»§
Linux°ïÖú

ubuntu11.04 °²×°mysql++×¢ÒâÊÂÏî

·¢²¼Ê±¼ä:2012-01-17 09:39:03À´Ô´:ºìÁª×÷Õß:haolifengwang
¼´Ê¹»ñµÃÀ´¡¶¿û»¨±¦µä¡·Ò²Î´±ØÄÜÁ¶³É¡°¶«·½²»°Ü¡±£¬»¹ÐèҪŬÁ¦ºÍ×êÑУ¡

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::RefCountedPointer()¡¯ÖÐ:

½â¾ö·½·¨£º´ò¿ª./lib/refcounted.h£¬Ìí¼Ó#include ºÍusing namespace std;

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
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 45 ÌõÆÀÂÛ

  1. loveline ÓÚ 2014-10-16 17:55:38·¢±í:

    Thanks for share

  2. sammas1025 ÓÚ 2014-10-05 16:17:16·¢±í:

    лл·ÖÏí

  3. mutou1991 ÓÚ 2014-09-25 17:24:38·¢±í:

    Â¥Ö÷˵µÄºÃ

  4. qxfsy ÓÚ 2014-08-09 15:21:06·¢±í:

    Á˽â¹þ£¡

  5. william2011 ÓÚ 2014-07-31 12:23:11·¢±í:

    лл·ÖÏí

  6. markvenus ÓÚ 2014-06-13 11:32:26·¢±í:

    ÎÒÊÇÐÂÊÖ£¬ÎÒҪѧϰ

  7. »ÆÉÜ¿­ ÓÚ 2014-06-09 14:01:30·¢±í:

    ºÃ°¡

  8. Ö´×Å×·Çó°® ÓÚ 2014-06-07 23:39:47·¢±í:

    ºÜÓÐÓÃ

  9. Ö´×Å×·Çó°® ÓÚ 2014-06-07 23:39:28·¢±í:

    ²»´í

  10. senke1 ÓÚ 2014-01-14 15:06:47·¢±í:

    (e:e2sÊܽÌÁË

  11. Jack561 ÓÚ 2014-01-13 15:20:36·¢±í:

    лл·ÖÏí

  12. idlerinwind ÓÚ 2013-09-30 11:45:53·¢±í:

    ŬÁ¦Ñ§Ï°Linux

  13. jyhll123 ÓÚ 2013-07-25 21:29:43·¢±í:

    ÊܽÌ

  14. bnmluo ÓÚ 2012-12-14 17:21:33·¢±í:

    À´Ñ§Ï°Ñ§Ï°

  15. ÓÚ 2012-12-12 10:29:59·¢±í:

    ѧϰÁË

  16. ÓÚ 2012-12-12 10:29:45·¢±í:

    ѧϰÁË£¬

  17. jdhongtao ÓÚ 2012-12-12 09:24:42·¢±í:

    ¶àл£¬¶¥ÆðÀ´

  18. ×í³¾·ç ÓÚ 2012-12-11 14:31:33·¢±í:

    ѧϰ

  19. gky2009514 ÓÚ 2012-12-07 12:51:26·¢±í:

    ÐÂÊÖÍê³ÉÈÎÎñ£¬ÇóÏÂÊé¼®~

  20. huangjie540 ÓÚ 2012-11-28 21:18:32·¢±í:

    ¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥¶¥:0wpoi2¡£Ð»Ð»Â¥Ö÷¶î

  21. yiiy88 ÓÚ 2012-11-28 18:17:50·¢±í:

    ÐÂÈËһö ²»»á°²×°ÈκÎÈí¼þ¡£

  22. ouyangcp ÓÚ 2012-10-08 15:04:00·¢±í:

    ¸Ð?ÄúµÄ½Ì?·ÖÏí!

  23. ¼ÅįÍ䵶 ÓÚ 2012-10-05 00:27:19·¢±í:

    ѧϰÁË£¡

  24. jiangjinta ÓÚ 2012-06-24 13:52:31·¢±í:

    ¾³½çÌ«¸ß£¬ÓеãÏñÌìÊé:0)1

  25. jiangjinta ÓÚ 2012-06-24 13:22:05·¢±í:

    ¸Ð¾õÏëÔÚ¿´ÌìÊéÒ»Ñù°¡(5ty(
    ŬÁ¦£¬¼ÓÓÍ

  26. liuyanqiu0807 ÓÚ 2012-06-14 17:12:54·¢±í:

    ¸Ðл¥Ö÷£¡

  27. fcyyy ÓÚ 2012-06-04 12:16:47·¢±í:

    qwqqq

  28. Lone_Arena ÓÚ 2012-05-09 11:06:47·¢±í:

    :0w5ty(1

  29. larmbr ÓÚ 2012-05-04 14:56:35·¢±í:

    ¸Ðл·ÖÏí£¬Ñ§Ï°ÁË£¬Ð»Ð»£¡£¡£¡

  30. ÓÚ 2012-04-18 15:45:36·¢±í:

    ¶¥°¡

  31. tan19880105 ÓÚ 2012-04-09 11:11:48·¢±í:

    ÎÒÊÇÐÂÊÖ

  32. lunan_gz ÓÚ 2012-04-09 10:48:40·¢±í:

    ¶¥

  33. toby_lund ÓÚ 2012-04-02 22:18:07·¢±í:

    Â¥Ö÷ÐÁ¿àÁË

  34. fate3008 ÓÚ 2012-03-30 10:34:08·¢±í:

    :0)1

  35. zyzhang12 ÓÚ 2012-03-07 03:23:52·¢±í:

    ÔÝʱδÓÃ

  36. linuxian ÓÚ 2012-03-01 20:06:49·¢±í:

    ¶¥Â¥Ö÷

  37. liulanghanzi ÓÚ 2012-02-20 16:43:06·¢±í:

    Â¥Ö÷˵µÃºÜ×Ðϸ

  38. ¾ý¾ýÙâÙâ ÓÚ 2012-02-17 21:43:54·¢±í:

    ÒªÊÇÓиöÊÓƵ½²½â¾ÍÍêÃÀÁË¡£

  39. Lee2012 ÓÚ 2012-02-11 08:32:36·¢±í:

    :0)1

  40. frankhht ÓÚ 2012-01-29 20:24:46·¢±í:

    ¶¥