title: Problem when linking mysqlcppconn-static using MySQL Connector C++
body: <p>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 (<a href="https://dev.mysql.com/doc/connector-cpp/1.1/en/connector-cpp-installation-binary.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/connector-cpp/1.1/en/connector-cpp-installation-binary.html</a>).</p>
  
  <p>In my project (Clion) I have this cmake file:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>The mySQL istallation I have is the one provided with XAMPP. So the directory where to find <code>mysqlclient.a</code> is <code>/opt/lampp/lib</code></p>
  
  <p>The problem is when linking <code>mysqlcppconn-static.a</code>, during compilation I obtain a long list of errors like the following:</p>
  
  <pre><code>/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"
  </code></pre>
  
  <p>Can someone explain me what does this mean? Can someone suggest me how to fix?</p>
  
  <p>Thanks in advance.</p>
  
  <p>[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:</p>
  
  <pre><code>/* Create a connection */
  driver = get_driver_instance();
  con = driver-&gt;connect("tcp://127.0.0.1:3306", "root", "root");
  /* Connect to the MySQL test database */
  con-&gt;setSchema("test");
  </code></pre>
  
  <p>I've found other posts regarding this issue, like <a href="https://stackoverflow.com/questions/39101671/c-mysql-connection-bad-alloc-using-c-connector?s=17aad964-56d7-4ecd-a2b0-a79e1db18cbf#new-answer">c++ mysql connection bad_alloc using c++ connector</a>
  but this doesn't help in linux, in particular i tried to follow the hint:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>Thanks</p>