3

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 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you, but still the same error unfortunately. I have updated the question as it was a bit difficult to see the error message If I try to use the last alternative I get "g++: error: =lmysqlcppconn8-static: No such file or directory"
Oops, sorry, that was a typo, it's -, not =.
Got it working eventually when I found out that I also had version 1.0 of openssl while I needed version 1.1.
@eirikaso How did you actually do the update? On my Ubuntu 18.04 machine the command openssl version returns OpenSSL 1.1.1 11 Sep 2018, however in the lib-directory, I find /usr/lib/x86_64-linux-gnu/openssl-1.0.0.
@ctenar Sorry, It's a long time ago and I don't remember. The PC i did it on has also been formatted

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.