2
votes

I'm trying to use the mySQL c++ connector. I have downloaded and extracted the binaries following the mysql guide https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-binary.html

When i include the xdevapi like so

#include <mysqlx/xdevapi.h>

I get the following errors

/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 tovtable 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 tomysqlx::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 tomysqlx::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

My Makefile look like this:

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 \

Does anyone know what I'm missing here?

1

1 Answers

4
votes

You are not linking with the MySQL library:

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

Use:

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

or:

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