mysql++ 安裝

來源:互聯網
上載者:User

標籤:

官網介紹:

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

[email protected] 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++ 安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.