码迷,mamicode.com
首页 > 数据库 > 详细

mysql++ 安装

时间:2015-10-14 23:18:20      阅读:402      评论:0      收藏:0      [点我收藏+]

标签:

官网介绍:

http://www.tangentsoft.net/mysql++/

MySQL++ is a C++ wrapper for MySQL’s C API. It is built around the same principles as the Standard C++ Library, to make dealing with the database as easy as dealing with STL containers. In addition, MySQL++ provides facilities that let you avoid the most repetitive sorts of SQL within your own code, providing native C++ interfaces for these common tasks.

MySQL++ should work on any platform that has a Standard C++ compiler and the MySQL C API development files. The code does use some C99/TR1 features that are widely supported in advance of full standardization, but these are optional.

 

 

linux安装:

tar -xvzf mysql++xxx.tar.gz

进入解压后的目录,一大堆文件,惯例------先看README,因为我的是ubuntu,所以就看README-Linux.txt

To build MySQL++, you must have the MySQL C API development
files installed.

On Unixy systems (Linux, Mac OS X, Cygwin, *BSD, Solaris...),
the MySQL development files are installed if you build MySQL
from source. If you installed MySQL as a binary package, then
the development files are often packaged separately from the
MySQL server itself. It‘s common for the package containing the
development files to be called something like "MySQL-devel".

If you‘re building on Windows with Visual C++ or MinGW, you
need to install the native Win32 port of MySQL from mysql.com.
The development files are only included with the "complete"
version of the MySQL installer, and some versions of this
installer won‘t actually install them unless you do a custom
install. Another pitfall is that MySQL++‘s project files assume
that you‘ve installed the current General Availability release of
MySQL (v5.0 right now) and it‘s installed in the default location.
If you‘ve installed a different version, or if MySQL Inc. changes
the default location (which they seem to do regularly!) you‘ll have
to adjust the link and include file paths in the project settings.

 

首先它告诉你,mysql++必须得有mysql c API才能正常工作,mysql c API就需要安装mysqlclient.

ubuntu下面执行下面命令就可以

sudo apt-get install libmysqlclient-dev

 其次它告诉你,为了防止动态链接器找不见,最好不要装在非主流的目录下,它建议你放/usr下面

./configure --prefix=/usr

执行建议的命令,它就开始检测文件,配置了.

(提示找不到:: Didn‘t find mysqlclient library 。手动指定,

./configure --prefix=/usr --with-mysql-lib=/usr/lib/x86_64-linux-gnu

我在xampp目录下找到了,指定为: --with-mysql-lib=/opt/lampp/lib 就行了。

make。make install

root@make install
mkdir -p /usr/lib
/usr/bin/install -c -m 644 libmysqlpp.so /usr/lib
/usr/bin/install -c libmysqlpp.so.3.2.2 /usr/lib
(cd /usr/lib ; rm -f libmysqlpp.so libmysqlpp.so.3; ln -s libmysqlpp.so.3.2.2 libmysqlpp.so.3; ln -s libmysqlpp.so.3 libmysqlpp.so)
mkdir -p /usr/include/mysql++
(cd . ; /usr/bin/install -c -m 644 lib/*.h /usr/include/mysql++)

去example下找个例子测试下:

编译simple1.cpp

g++ -o simple1 simple1.cpp
simple1.cpp:28:21: fatal error: cmdline.h: No such file or directory
#include "cmdline.h"
^
compilation terminated.

locate cmdline.h一下,发现在/usr/include/mysql++/cmdline.h,

g++ -o simple1 simple1.cpp  -I  /usr/include/mysql++

又报错:

/usr/include/mysql++/common.h:133:28: fatal error: mysql_version.h: No such file or directory
# include <mysql_version.h>

我电脑是上mysql头文件是在/opt/lampp/include目录下的。(一般是在/usr/include/mysql下)。

g++ -o test simple1.cpp -I /usr/include/mysql++/ -I /usr/include/mysql -lmysqlpp

 类似这样。

g++ -o simple1 simple1.cpp  -I  /usr/include/mysql++  -I /opt/lampp/include -lmysqlpp

ok,终于成功了。

执行完成,有错误,说:

connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock

我用的是xampp,locate下mysql.sock文件,然后创建个软link就行了。

ln -s  /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

(plus:在mysql的配置文件里,/opt/lampp/etc/my.cnf, 发现了这样的配置:

 
[java] 
<span style="font-size:24px;"># The following options will be passed to all MySQL clients  
[client]  
#password       = your_password  
port            = 3306  
socket          = /opt/lampp/var/mysql/mysql.sock  
  
# Here follows entries for some specific programs  
  
# The MySQL server  
[mysqld]  
user            = nobody  
port            = 3306  
socket          = /opt/lampp/var/mysql/mysql.sock  
  这个是我们自己可以改动的)
 
 

参考:http://www.cnblogs.com/comoon/p/4104482.html?utm_source=tuicool

 

mysql++ 安装

标签:

原文地址:http://www.cnblogs.com/youxin/p/4881044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!