使用 mysql c++ 连接器的未定义引用
Undefined reference using the mysql c++ connector
我正在尝试使用 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: In function `mysqlx::string::operator std::__cxx11::basic_string, std::allocator >abi:cxx11 const':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/common.h:115: undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
/tmp/cc6dzD4k.o: In function `mysqlx::DbDoc::DbDoc()':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:153: undefined reference to `vtable for mysqlx::DbDoc'
/tmp/cc6dzD4k.o: In function 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
vtable for mysqlx::DbDoc'
/tmp/cc6dzD4k.o: In function 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 to
mysqlx::common::Value::print(std::ostream&) const'
/tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x18): undefined reference to typeinfo for mysqlx::common::Value'
/tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x20): undefined reference to
mysqlx::common::Value::print(std::ostream&) const'
/tmp/cc6dzD4k.o:(.rodata._ZTIN6mysqlx5ValueE[_ZTIN6mysqlx5ValueE]+0x28): undefined reference to `typeinfo for mysqlx::common::Value'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'x86' failed
make: *** [x86] Error 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
我正在尝试使用 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: In function `mysqlx::string::operator std::__cxx11::basic_string, std::allocator >abi:cxx11 const':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/common.h:115: undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
/tmp/cc6dzD4k.o: In function `mysqlx::DbDoc::DbDoc()':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:153: undefined reference to `vtable for mysqlx::DbDoc'
/tmp/cc6dzD4k.o: In function
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
vtable for mysqlx::DbDoc'/tmp/cc6dzD4k.o: In function
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 to
mysqlx::common::Value::print(std::ostream&) const'/tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x18): undefined reference to
typeinfo for mysqlx::common::Value' /tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x20): undefined reference to
mysqlx::common::Value::print(std::ostream&) const'/tmp/cc6dzD4k.o:(.rodata._ZTIN6mysqlx5ValueE[_ZTIN6mysqlx5ValueE]+0x28): undefined reference to `typeinfo for mysqlx::common::Value'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'x86' failed
make: *** [x86] Error 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