﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-技术博客-随笔分类-c/c++</title><link>http://www.cppblog.com/chenjunjun/category/20951.html</link><description>c/c++/python/linux</description><language>zh-cn</language><lastBuildDate>Fri, 19 Sep 2014 13:41:08 GMT</lastBuildDate><pubDate>Fri, 19 Sep 2014 13:41:08 GMT</pubDate><ttl>60</ttl><item><title>vs 2013 配置 asio 开发环境</title><link>http://www.cppblog.com/chenjunjun/archive/2014/09/17/208346.html</link><dc:creator>chenjunjun</dc:creator><author>chenjunjun</author><pubDate>Wed, 17 Sep 2014 10:22:00 GMT</pubDate><guid>http://www.cppblog.com/chenjunjun/archive/2014/09/17/208346.html</guid><wfw:comment>http://www.cppblog.com/chenjunjun/comments/208346.html</wfw:comment><comments>http://www.cppblog.com/chenjunjun/archive/2014/09/17/208346.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chenjunjun/comments/commentRss/208346.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chenjunjun/services/trackbacks/208346.html</trackback:ping><description><![CDATA[<div>### 我的环境<br /><br />&nbsp;&nbsp; &nbsp;操作系统：windows 7 x64 sp1<br />&nbsp;&nbsp; &nbsp;VS版本：VS 2013<br />&nbsp;&nbsp; &nbsp;Boost版本：1.56.0<br /><br />### 下载boost<br /><br />&nbsp;&nbsp; &nbsp;官网：www.boost.org<br /><br />&nbsp;&nbsp; &nbsp;下载预编译版本的boost：http://sourceforge.net/projects/boost/files/boost-binaries/<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;我下载的版本：<br />&nbsp;&nbsp; &nbsp;http://sourceforge.net/projects/boost/files/boost-binaries/1.56.0/boost_1_56_0-msvc-12.0-32.exe/download<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;<br />### 安装<br /><br />&nbsp;&nbsp; &nbsp;直接运行下载exe文件，可以选择安装路径。<br />&nbsp;&nbsp; &nbsp;我的安装目录为：E:\lib\boost_1_56_0<br />&nbsp;&nbsp; &nbsp;<br />### 创建测试项目<br /><br />&nbsp;&nbsp; &nbsp;我创建的项目为：boost_asio_test<br /><br />### 配置项目<br /><br />#### 配置 boost asio 头文件<br /><br />&nbsp;&nbsp; &nbsp;右键项目属性，弹出配置窗口；<br />&nbsp;&nbsp; &nbsp;点击在配置属性-&gt;C/C++-&gt;常规-&gt;附加包含目录,出现下拉菜单，点击编辑，弹出窗口；<br />&nbsp;&nbsp; &nbsp;点击右右上角新建一条记录，内容为boost的安装路径：E:\lib\boost_1_56_0<br /><br />#### 配置 boost asio 库目录<br /><br />&nbsp;&nbsp; &nbsp;右键项目属性，弹出配置窗口；<br />&nbsp;&nbsp; &nbsp;点击在配置属性-&gt;连接器-&gt;常规-&gt;附加库目录, 出现下拉菜单，点击编辑，弹出窗口；<br />&nbsp;&nbsp; &nbsp;点击右右上角新建一条记录，内容为boost的安装路径中的库路径：E:\lib\boost_1_56_0\lib32-msvc-12.0<br /><br />#### 配置 boost asio 库文件<br /><br />&nbsp;&nbsp; &nbsp;库 date_time和 system 是 boost asio 的必须库。<br />&nbsp;&nbsp; &nbsp;右键项目属性，弹出配置窗口；<br />&nbsp;&nbsp; &nbsp;点击配置属性-&gt;连接器-&gt;输入-&gt;附加依赖项,出现下拉菜单，点击编辑，弹出窗口；<br />&nbsp;&nbsp; &nbsp;在上方的窗口中填写入:boost_date_time-vc120-mt-1_56.lib, boost_system-vc120-mt-1_56.lib 每行一条，这里为两行<br />&nbsp;&nbsp; &nbsp;<br />### 测试<br /><br />#include "stdafx.h"<br /><br />#include "boost/asio.hpp"<br /><br />using namespace boost::asio;<br /><br /><br />int _tmain(int argc, _TCHAR* argv[])<br />{<br />&nbsp;&nbsp; &nbsp;io_service io;<br />&nbsp;&nbsp; &nbsp;return 0;<br />}<br /><br />运行报错：<br />丢失 boost_system-vc120-mt-1_56.dll需要配置运行时的库：<br /><br />从boost库目录E:\lib\boost_1_56_0\lib32-msvc-12.0中复制：boost_date_time-vc120-mt-1_56.dll和boost_system-vc120-mt-1_56.dll到生成的exe文件目录下。<br />我的exe文件目录为:项目目录/Debug<br /><br />再次运行OK！</div><img src ="http://www.cppblog.com/chenjunjun/aggbug/208346.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chenjunjun/" target="_blank">chenjunjun</a> 2014-09-17 18:22 <a href="http://www.cppblog.com/chenjunjun/archive/2014/09/17/208346.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>centos 6.5 x86-64 下编译安装mysql_connector_c++</title><link>http://www.cppblog.com/chenjunjun/archive/2014/08/12/207986.html</link><dc:creator>chenjunjun</dc:creator><author>chenjunjun</author><pubDate>Tue, 12 Aug 2014 09:01:00 GMT</pubDate><guid>http://www.cppblog.com/chenjunjun/archive/2014/08/12/207986.html</guid><wfw:comment>http://www.cppblog.com/chenjunjun/comments/207986.html</wfw:comment><comments>http://www.cppblog.com/chenjunjun/archive/2014/08/12/207986.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chenjunjun/comments/commentRss/207986.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chenjunjun/services/trackbacks/207986.html</trackback:ping><description><![CDATA[### 安装依赖<br /><div><br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ su -<br />&nbsp;&nbsp; &nbsp;Password:<br />&nbsp;&nbsp; &nbsp;[root@localhost ~]# yum install wget cmake gcc-c++ boost-devel mysql-devel<br />&nbsp;&nbsp; &nbsp;[root@localhost ~]# exit<br />&nbsp;&nbsp; &nbsp;logout<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$<br /><br />### 编译安装mysql-connector-c++<br /><br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ wget http://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-1.1.4.tar.gz<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ tar zxvf mysql-connector-c++-1.1.4.tar.gz<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ cd mysql-connector-c++-1.1.4<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost mysql-connector-c++-1.1.4]$ mkdir build<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost mysql-connector-c++-1.1.4]$ cd&nbsp; build<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost build]$ cmake -DCMAKE_INSTALL_PREFIX=/home/chenjunjun/usr/mysql_connect_c++/ -DMYSQL_LIB=/usr/lib64/mysql/libmysqlclient.so ..<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost build]$ make <br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost build]$ vim cppconn/cmake_install.cmake<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 38&nbsp;&nbsp;&nbsp;&nbsp; "/home/chenjunjun/mysql-connector-c++-1.1.4/cppconn/config.h"<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;==修改为==&gt;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 38&nbsp;&nbsp;&nbsp;&nbsp; "/home/chenjunjun/mysql-connector-c++-1.1.4/build/cppconn/config.h"<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost build]$ make install<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost build]$ cd<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ <br /><br />### 设置<br /><br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ echo "export LD_LIBRARY_PATH=~/usr/mysql_connect_c++/lib/" &gt;&gt; ~/.bashrc<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ . ./.bashrc<br /><br />### 测试<br /><br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ vi test.cc<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#include &lt;iostream&gt;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#include &lt;string&gt;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#include &lt;mysql_connection.h&gt;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#include &lt;mysql_driver.h&gt;<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;using namespace std;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;using namespace sql;<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int main(){<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Driver* driver;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Connection* conn;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;driver = get_driver_instance();<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;conn = driver-&gt;connect("数据库地址", "用户名", "用户密码");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;conn-&gt;setAutoCommit(1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout &lt;&lt; "DataBase connection autocommit mode = " &lt;&lt; conn-&gt;getAutoCommit() &lt;&lt; endl;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;delete conn;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;driver = NULL;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;conn = NULL;<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return 0;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ g++ test.cc -I ~/usr/mysql_connect_c++/include -L ~/usr/mysql_connect_c++/lib -l mysqlcppconn -o test<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$ ./test<br />&nbsp;&nbsp; &nbsp;DataBase connection autocommit mode = 1<br />&nbsp;&nbsp; &nbsp;[chenjunjun@localhost ~]$</div><img src ="http://www.cppblog.com/chenjunjun/aggbug/207986.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chenjunjun/" target="_blank">chenjunjun</a> 2014-08-12 17:01 <a href="http://www.cppblog.com/chenjunjun/archive/2014/08/12/207986.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>