在Linux中设置Mysql ++ [英] Setting up Mysql++ in linux

查看:86
本文介绍了在Linux中设置Mysql ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Linux中使用C ++连接到mysql数据库.在我的本地计算机上,我正在运行Ubuntu,并安装了mysql服务器和客户端软件包:

I want to connect to a mysql database with C++ in linux. On my local machine I am running Ubuntu, and installed the mysql server and client packages:

sudo apt-get install mysql-server mysql-client

sudo apt-get install mysql-server mysql-client

我遇到了 Mysql ++ ,但是从其二进制包运行./configure时遇到了一些问题.错误提示:

I came across Mysql++ but have some problems when running ./configure from their binary package. The error says:

正在检查MySQL库目录...配置:错误:在'/usr/lib64/usr/lib/usr/lib64/mysql/usr/lib/mysql/usr/local/lib64/中找不到mysqlclient库usr/local/lib/usr/local/lib/mysql/usr/local/mysql/lib/usr/local/mysql/lib/mysql/usr/mysql/lib/mysql/opt/mysql/lib/opt/mysql/lib/mysql/sw/lib/sw/lib/mysql'

checking for MySQL library directory... configure: error: Didn't find mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql /usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib /usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib /opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'

我看到可以在哪里使用此命令指定路径:

I see where I can use this command to specify the path:

./configure --with-mysql-lib =/...

./configure --with-mysql-lib=/...

,但我不知道该指向何处.我使用whereis mysql,但是找不到包含lib子目录的任何mysql目录. mysqlclient库将安装在哪里?

找到位置libmysqlclient之后,我回来了

After doing locate libmysqlclient I got back

/usr/lib/i386-linux-gnu/libmysqlclient.so.18
/usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.0.0
/usr/share/doc/libmysqlclient18
/usr/share/doc/libmysqlclient18/changelog.Debian.gz
/usr/share/doc/libmysqlclient18/copyright
/var/cache/apt/archives/libmysqlclient18_5.5.22-0ubuntu1_i386.deb
/var/lib/dpkg/info/libmysqlclient18:i386.list
/var/lib/dpkg/info/libmysqlclient18:i386.md5sums
/var/lib/dpkg/info/libmysqlclient18:i386.postinst
/var/lib/dpkg/info/libmysqlclient18:i386.postrm
/var/lib/dpkg/info/libmysqlclient18:i386.shlibs

/usr/lib/i386-linux-gnu/libmysqlclient.so.18
/usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.0.0
/usr/share/doc/libmysqlclient18
/usr/share/doc/libmysqlclient18/changelog.Debian.gz
/usr/share/doc/libmysqlclient18/copyright
/var/cache/apt/archives/libmysqlclient18_5.5.22-0ubuntu1_i386.deb
/var/lib/dpkg/info/libmysqlclient18:i386.list
/var/lib/dpkg/info/libmysqlclient18:i386.md5sums
/var/lib/dpkg/info/libmysqlclient18:i386.postinst
/var/lib/dpkg/info/libmysqlclient18:i386.postrm
/var/lib/dpkg/info/libmysqlclient18:i386.shlibs

所以,我尝试了./configure --with-mysql-lib=/usr/lib/i386-linux-gnu,它似乎完成了,没有任何抱怨.

So, I tried ./configure --with-mysql-lib=/usr/lib/i386-linux-gnu and it seems to complete without any complaining.

尽管这解决了完成./configure的问题,但我仍然遇到更多麻烦.当我运行make之前,一切都很好:

Although this solves the problem of getting ./configure to complete, I still have further troubles. When I run make things go fine until this point:

在./lib/sql_buffer.h:31:0包含的文件中, 来自./lib/sql_buffer.cpp:26:./lib/refcounted.h:258:2:错误:'size_t'没有命名类型 ./lib/refcounted.h:在构造函数"mysqlpp :: RefCountedPointer :: RefCountedPointer()"中:./lib/refcounted.h:89:2:错误: 类"mysqlpp :: RefCountedPointer"没有任何内容 名为"refs_"的字段./lib/refcounted.h:在构造函数中 ‘mysqlpp :: RefCountedPointer :: RefCountedPointer(T *)’: ./lib/refcounted.h:100:2:错误:类"mysqlpp :: RefCountedPointer"没有任何名为"refs_"的字段 ./lib/refcounted.h:104:4:错误:未在此声明"refs_" 范围./lib/refcounted.h:104:16:错误:预期的类型说明符之前 ‘size_t’./lib/refcounted.h:104:16:错误:预期为';'之前 ‘size_t’./lib/refcounted.h:在构造函数中 ‘mysqlpp :: RefCountedPointer :: RefCountedPointer(const ThisType&)’:./lib/refcounted.h:112:2:错误:类 "mysqlpp :: RefCountedPointer"没有任何字段 名为"refs _"./lib/refcounted.h:115:8:错误:"refs_"不是 在此范围内声明的./lib/refcounted.h:在析构函数中 ‘mysqlpp :: RefCountedPointer ::〜RefCountedPointer()’: ./lib/refcounted.h:125:7:错误:未在此声明"refs_" scope ./lib/refcounted.h:在成员函数‘void中 mysqlpp :: RefCountedPointer :: swap(mysqlpp :: RefCountedPointer :: ThisType&)':./lib/refcounted.h:246:13:错误:"refs_"为 未在此范围内声明:*** [mysqlpp_sql_buffer.o]错误1

In file included from ./lib/sql_buffer.h:31:0, from ./lib/sql_buffer.cpp:26: ./lib/refcounted.h:258:2: error: ‘size_t’ does not name a type ./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer()’: ./lib/refcounted.h:89:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’ ./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer(T*)’: ./lib/refcounted.h:100:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’ ./lib/refcounted.h:104:4: error: ‘refs_’ was not declared in this scope ./lib/refcounted.h:104:16: error: expected type-specifier before ‘size_t’ ./lib/refcounted.h:104:16: error: expected ‘;’ before ‘size_t’ ./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer(const ThisType&)’: ./lib/refcounted.h:112:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’ ./lib/refcounted.h:115:8: error: ‘refs_’ was not declared in this scope ./lib/refcounted.h: In destructor ‘mysqlpp::RefCountedPointer::~RefCountedPointer()’: ./lib/refcounted.h:125:7: error: ‘refs_’ was not declared in this scope ./lib/refcounted.h: In member function ‘void mysqlpp::RefCountedPointer::swap(mysqlpp::RefCountedPointer::ThisType&)’: ./lib/refcounted.h:246:13: error: ‘refs_’ was not declared in this scope make: *** [mysqlpp_sql_buffer.o] Error 1

我对C ++并不是很熟悉,所以我不确定错误的确切含义.从这一点上如何获得Mysql ++安装程序的任何帮助或指导将不胜感激.虽然,我承认我也开始寻找替代库来使用.

I'm not really familiar with C++, so I'm not sure what the error means exactly. Any help or direction on how to get Mysql++ setup from this point would be much appreciated. Although, I admit that I'm also starting to look for alternative libraries to use.

推荐答案

之所以会出现此问题,是因为size_t依赖于在配置(make)文件中调用stddef命名空间之前将其包含在内.

this problem is caused because size_t depends on the inclusion of stddef namespace before it is called in the configuration (make) files.

我遇到了同样的问题(使用Amazon EC2 ubuntu 12.04云服务器),并通过编辑有问题的文件(在我的情况下为/home/ubuntu/mysql++-3.1.0/lib)解决了该问题.并包括stddef(同时还将字符串命名空间上移):

i had the very same problem (using an amazon EC2 ubuntu 12.04 cloud server) and solved it by editing the offending file (sql_buffer.cpp located, in my case, /home/ubuntu/mysql++-3.1.0/lib) and including stddef (while also moving string namespace up):

#include <stddef.h>
#include <string.h>
#include "sql_buffer.h"

此更正可以回答您的问题.但是,您可能会像我一样遇到其他问题.因此,我解释了如何解决一些后续的问题,您可能也可能没有.

your question is answered with this correction. BUT, you might have additional problems, like i did. so i explain how i solved some subsequent problems, which you might or might not have also.

您可能必须使用

sudo chown username sql_buffer.cpp

能够编辑文件,具体取决于安装的安装方式(例如,我是ubuntu用户).

to be able to edit the file, depending on how your install is setup (i am user ubuntu, for example).

然后我遇到另一个问题:

i then bumped into another problem:

./ssx/genv2.cpp: In function âbool generate_ssqls2(const char*, const ParseV2*)â:
./ssx/genv2.cpp:70:28: error: âstrcmpâ was not declared in this scope

所以我编辑了有问题的文件(genv2.cpp)并包含了字符串命名空间

so i edited the offending file (genv2.cpp) and included string namespace

#include <string.h>

然后我还有另一个问题:

then i had ANOTHER problem with:

./libmysqlpp_ssqls2parse.a(ssqls2parse_parsev2.o): In function `Type':
/home/ubuntu/mysql++-3.1.0/./ssx/parsev2.cpp:256: undefined reference to `mysqlpp::internal::str_to_lwr

我本可以编辑Makefile.in,但选择只在命令行中运行:

i could have edited Makefile.in but chose to simply run in command line:

sudo  g++ -o test_ssqls2 test_ssqls2_ssqls2.o -lmysqlpp_ssqls2parse   -L. -lmysqlclient   -L/usr/lib/x86_64-linux-gnu  -lmysqlpp

然后

i继续make过程.

:mysql ++已安装并正在运行.

that worked for me: mysql++ installed and running.

这篇关于在Linux中设置Mysql ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆