使用mysql c++连接器的未定义引用

Undefined reference using the mysql c++ connector

本文关键字:未定义 引用 连接器 mysql c++ 使用      更新时间:2023-10-16

我正在尝试使用mySQL c++连接器。我已经按照mysql指南下载并提取了二进制文件https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-binary.html

当我包括类似这样的xdevapi 时

#include <mysqlx/xdevapi.h>

我得到以下错误

/tmp/cc6dzD4k.o:在函数"mysqlx::string::operator std::__cxx11::basic_string,std::allocater>abi:cxx11 const"中:

/git_repos/FHM/Camer/Software/TextractMetadata/Build/Linux/../..//mysql-connector-c++-8.13/include/mysqlx/devapi/common.h:115:对`mysqlx::string::Impl::to_utf8[abi:cx_11](mysqlx:;string const&('的未定义引用

/tmp/cc6dzD4k.o:在函数"mysqlx::DbDoc::DbDoc(("中:

/git_repos/FHM/Camer/Software/TextractMetadata/Build/Linux/../..//mysql-connector-c++-8.13/include/mysqlx/devapi/document.h:153:对`vtable for mysqlx::DbDoc'的未定义引用

/tmp/cc6dzD4k.o:在函数mysqlx::DbDoc::~DbDoc()': /git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:127: undefined reference to中,适用于mysqlx的vtable::DbDoc’

/tmp/cc6dzD4k.o:在函数mysqlx::Value::print(std::ostream&) const': /git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:507: undefined reference tomysqlx::common::Value::print(std::ostream&(const‘中

/tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x18(:对typeinfo for mysqlx::common::Value' /tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x20): undefined reference tomysqlx::common::Value::print(std::ostream&(const‘的未定义引用

/tmp/cc6dzD4k.o:(.rodata._ZTIN6mysqlx5ValueE[_ZTIN6m ysqlx5valueE]+0x28(:对"mysqlx::common::Value的类型信息"的未定义引用

collect2:错误:ld返回1退出状态

生成文件:2:目标"x86"的配方失败

make:***[x86]错误1

我的Makefile看起来像这样:

g++ -I../../Src -I../../../Fee/Src 
-I/../../../OpenCV/include/opencv 
-I../../../OpenCV/include/opencv2 
-I../../../mysql-connector-c++-8.0.13/include/ 
-L../../../OpenCV/lib/LinX86 
-L../../../mysql-connector-c++-8.0.13/lib64/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread 
-g -D LINUX -o extractmetadata ../../Src/extractMetadata.cpp ../../../Fee/Src/Status.cpp 
-std=c++11 
-lopencv_world -lstdc++fs 

有人知道我在这里错过了什么吗?

您没有链接到MySQL库:

-L../../../mysql-connector-c++-8.0.13/lib64/libmysqlcppconn8-static.a

用途:

../../../mysql-connector-c++-8.0.13/lib64/libmysqlcppconn8-static.a

或:

-L../../../mysql-connector-c++-8.0.13/lib64/ -lmysqlcppconn8-static