免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3998 | 回复: 5
打印 上一主题 下一主题

[Redis] 【救助】FreeBSD下用C/C++联Redis [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-30 11:10 |只看该作者 |倒序浏览
救助有经验的朋友,我在FreeBSD下使用C++来联Redis,但总是编译不成功,我已经安装过boost,希望大家不吝赐教,感谢
  1. [root@jiangpo /home/Jolr/redis]# make
  2. g++ -c -O2 -pipe  test_client.cpp
  3. In file included from test_client.cpp:1:
  4. redisclient.h:45:35: error: boost/concept_check.hpp: No such file or directory
  5. redisclient.h:46:34: error: boost/lexical_cast.hpp: No such file or directory
  6. redisclient.h:47:37: error: boost/functional/hash.hpp: No such file or directory
  7. redisclient.h:48:29: error: boost/foreach.hpp: No such file or directory
  8. redisclient.h:49:34: error: boost/thread/mutex.hpp: No such file or directory
  9. redisclient.h:50:47: error: boost/thread/condition_variable.hpp: No such file or directory
  10. redisclient.h:51:28: error: boost/random.hpp: No such file or directory
  11. redisclient.h:52:29: error: boost/cstdint.hpp: No such file or directory
  12. redisclient.h:53:48: error: boost/date_time/posix_time/ptime.hpp: No such file or directory
  13. redisclient.h:54:59: error: boost/date_time/posix_time/posix_time_types.hpp: No such file or directory
  14. redisclient.h:55:30: error: boost/optional.hpp: No such file or directory
  15. redisclient.h:56:29: error: boost/variant.hpp: No such file or directory
  16. test_client.cpp:4:31: error: boost/date_time.hpp: No such file or directory
  17. In file included from test_client.cpp:1:
  18. redisclient.h:107: error: 'boost' has not been declared
  19. redisclient.h:107: error: ISO C++ forbids declaration of 'uint16_t' with no type
  20. redisclient.h:107: error: expected ';' before 'port'
  21. redisclient.h: In constructor 'redis::connection_data::connection_data(const std::string&, uint16_t, int)':
  22. redisclient.h:90: error: class 'redis::connection_data' does not have any field named 'port'
  23. redisclient.h: In member function 'bool redis::connection_data::operator==(const redis::connection_data&) const':
  24. redisclient.h:98: error: 'port' was not declared in this scope
  25. redisclient.h:98: error: 'const struct redis::connection_data' has no member named 'port'
  26. redisclient.h: At global scope:
  27. redisclient.h:273: error: 'boost' has not been declared
  28. redisclient.h:273: error: ISO C++ forbids declaration of 'optional' with no type
  29. redisclient.h:273: error: expected ';' before '<' token
  30. .....................
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-10-30 14:14 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
3 [报告]
发表于 2012-10-30 22:21 |只看该作者
回复 2# stephen_du

我是使用ports安装的,都不知道把他们装到哪了。

   

论坛徽章:
1
射手座
日期:2013-08-21 13:11:46
4 [报告]
发表于 2012-10-30 22:46 |只看该作者
一般不在/usr/include下面,就在/usr/local/include下面

论坛徽章:
0
5 [报告]
发表于 2012-10-31 13:15 |只看该作者
egmkang 发表于 2012-10-30 22:46
一般不在/usr/include下面,就在/usr/local/include下面



谢谢 egmkang指点,可以告诉我具体怎么打命令么,make和 g++怎么指路径?
我在使用C++联mysql时也遇到类似问题,使用的是g++命令编译,但不知道怎么指定目录,我C++基本比较差,

  1. #include <iostream>
  2. #include <include/mysql.h>
  3. #include <string>

  4. using namespace std;

  5. int main() {
  6.     MYSQL mysql;
  7.     MYSQL_RES * mysql_ret;
  8.     MYSQL_ROW mysql_row;
  9.     int ret;

  10.     mysql_init(&mysql);
  11.     mysql_real_connect(&mysql, "localhost", "root", "123321", "mysql", 3306, NULL, 0);
  12.     string sql = "select * from mysql";
  13.     ret = mysql_query(&mysql, "select * from user");
  14.     if (ret) {
  15.         //cout << "OK" << endl;

  16.     } else {
  17.         mysql_ret   =   mysql_store_result(&mysql);
  18.         while(mysql_row   =   mysql_fetch_row(mysql_ret))  {
  19.             //printf( "%s\t%s\t%s\t%s\t%s\t%s\n ",mysql_row[0],mysql_row[1],mysql_row[2],mysql_row[3],mysql_row[4],mysql_row[5]);
  20.             cout << mysql_row[1] << endl;
  21.         }
  22.     }
  23.     mysql_close(&mysql);
  24. }
复制代码

论坛徽章:
0
6 [报告]
发表于 2012-10-31 14:25 |只看该作者
我在FreeBSD下使用C++联mysql搞定了,使用编译命令是
  1. g++ mysql.cpp -I /usr/local/include -L /usr/local/lib/mysql -l mysqlclient
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP