当前位置:Gxlcms > 数据库问题 > mysql++ 安装

mysql++ 安装

时间:2021-07-01 10:21:17 帮助过:2人阅读

es. 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++ 安装

标签:

人气教程排行