I am writing about a problem I had during the setup of MySQL Connector C++. I am using the binary distribution of the connector for Linux (Ubuntu 18.04), so I put the library directory outside my project (that is one of the examples given in the reference guide here (https://dev.mysql.com/doc/connector-cpp/1.1/en/connector-cpp-installation-binary.html).
In my project (Clion) I have this cmake file:
cmake_minimum_required(VERSION 3.14)
project(MySQLConnectorTest)
set(CMAKE_CXX_STANDARD 14)
link_directories(../mysql-connector-c++/lib64)
link_directories(/opt/lampp/lib)
add_executable(MySQLConnectorTest main.cpp)
include_directories(../mysql-connector-c++/include/jdbc)
target_link_libraries(MySQLConnectorTest mysqlclient.a)
target_link_libraries(MySQLConnectorTest mysqlcppconn-static.a)
The mySQL istallation I have is the one provided with XAMPP. So the directory where to find mysqlclient.a
is /opt/lampp/lib
The problem is when linking mysqlcppconn-static.a
, during compilation I obtain a long list of errors like the following:
/home/riccardo/MySQLConnectorTest/../mysql-connector-c++/lib64/libmysqlcppconn-static.a(libmysqlclient_client.cc.o):
nella funzione "ssl_verify_server_cert(Vio*, char const*, char const**) [clone .isra.7]":
./obj/libmysql/../../mysql-8.0.16/sql-common/client.cc:3283: riferimento non definito a "SSL_get_peer_certificate"
./obj/libmysql/../../mysql-8.0.16/sql-common/client.cc:3288: riferimento non definito a "SSL_get_verify_result"
./obj/libmysql/../../mysql-8.0.16/sql-common/client.cc:3359: riferimento non definito a "X509_free"
./obj/libmysql/../../mysql-8.0.16/sql-common/client.cc:3302: riferimento non definito a "X509_check_host"
./obj/libmysql/../../mysql-8.0.16/sql-common/client.cc:3304: riferimento non definito a "X509_check_ip_asc"
Can someone explain me what does this mean? Can someone suggest me how to fix?
Thanks in advance.
[EDIT]: following the suggestion provided here, the compilation now goes fine. I think there is still one problem, the example program throws an exception when calling the connect method:
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
/* Connect to the MySQL test database */
con->setSchema("test");
I've found other posts regarding this issue, like c++ mysql connection bad_alloc using c++ connector but this doesn't help in linux, in particular i tried to follow the hint:
I had the same error on linux. The error was : I was using g++-4.8 to build the project The issue lies on the version of the build tools (gcc,msvs,clang) used to build the project by trying to update g++, but I have tha latest version. Probably is more difficult to make this library work than writing the code I need for my application, I hope someone can suggest me what to try next.
Thanks