Unable to build my-sql-connector-c++ with CMake


I am trying to connect and interact with a mysql db running on my local, in a c++ project. I am also using cmake to compile my project.


I installed mysqlconnector cpp by using mysql-connector-odbc-8.0.25-macos11-x86-64bit.dmg from their community downloads. I have the include and lib files available at /usr/local/mysql-connector-c+


Part of my CMakeLists.txt which deals with mysqlconnector is referenced below:

cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR "/usr/local/mysql-connector-c++")
add_executable(runservice main.cpp)
target_link_libraries(runservice mysqlcppconn)

The cmake command runs fine.

Build Error

When I try to build using '''make``` command, I get the following error :

Undefined symbols for architecture x86_64:
  "mysqlx::abi2::r0::common::Value::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const", referenced from:
      mysqlx::abi2::r0::Value::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in main.cpp.o
      construction vtable for mysqlx::abi2::r0::common::Value-in-mysqlx::abi2::r0::Value in main.cpp.o
  "typeinfo for mysqlx::abi2::r0::common::Value", referenced from:
      construction vtable for mysqlx::abi2::r0::common::Value-in-mysqlx::abi2::r0::Value in main.cpp.o
      typeinfo for mysqlx::abi2::r0::Value in main.cpp.o
  "vtable for mysqlx::abi2::r0::DbDoc", referenced from:
      mysqlx::abi2::r0::Value::~Value() in main.cpp.o
      __GLOBAL__sub_I_main.cpp in main.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [runservice] Error 1
make[1]: *** [CMakeFiles/runservice.dir/all] Error 2
make: *** [all] Error 2

I can't understand this error or how to go about solving this.

Thank you for your precious time