微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在linux中设置Mysql

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

sudo apt-get install MysqL-server MysqL-client

我遇到了Mysql++,但是从他们的二进制包运行./configure时遇到了一些问题.错误说:

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

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

./configure –with-MysqL-lib=/…

但我不知道在哪里指出它.我使用whereis MysqL但找不到任何包含lib子目录的MysqL目录. MysqLclient库在哪里安装?

编辑:

找到libMysqLclient后我回来了

/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,似乎完成没有任何抱怨.

虽然这解决了完成./configure完成的问题,但我仍然有进一步的麻烦.当我跑步时让事情变好,直到这一点:

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设置的任何帮助或指导将非常感激.虽然,我承认我也开始寻找可供使用的替代库.

解决方法

导致此问题的原因是size_t在配置(make)文件调用之前依赖于stddef命名空间的包含.

我有同样的问题(使用亚马逊EC2 ubuntu 12.04云服务器)并通过编辑有问题的文件(在我的情况下,sql_buffer.cpp位于/ home / ubuntu / MysqL -3.1.0 / lib)并包括stddef来解决它(同时还要移动字符串命名空间):

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

这个更正回答了你的问题.但是,你可能还有其他问题,就像我一样.所以我解释了我是如何解决你可能会或可能不会遇到的一些后续问题的.

你可能不得不使用

sudo chown username sql_buffer.cpp

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

然后我遇到了另一个问题:

./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)并包含了字符串命名空间

#include <string.h>

然后我有一个问题:

./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但是选择只是在命令行中运行:

sudo  g++ -o test_ssqls2 test_ssqls2_ssqls2.o -lMysqLpp_ssqls2parse   -L. -lMysqLclient   -L/usr/lib/x86_64-linux-gnu  -lMysqLpp

然后我继续制作过程.

这对我有用:安装并运行MysqL.

原文地址:https://www.jb51.cc/linux/393063.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐