title: MySQL and MariaDB library's in C++ using cmake, mingw
body: <p><strong>STARTIG WITH MYSLQ CONNECTOR - here is the cmakelists.txt file that I use to generate build system using CMAKE GUI on windows (cause I actually have to make console application in c++ for windows).</strong></p>
  <pre><code>cmake_minimum_required(VERSION 3.16) # Or whatever version you use
  set(CMAKE_CXX_STANDARD 17)
  # THIS HAS TO COME BEFORE THE PROJECT LINE
  
  # THIS HAS TO COME BEFORE THE PROJECT LINE
  project(test VERSION 0.0.0 LANGUAGES C CXX)
  project(main)
  set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR &quot;C:\\connector&quot;)
  include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}\\include)
  
  link_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}\\lib64\\v14)
  add_executable(test main.cpp)
  target_link_libraries(test C:/connector/lib64/vs14/mysqlcppconn.lib)
  
  target_compile_features(test PRIVATE cxx_range_for)  
  set(STDFS_LIB stdc++fs)
  
  </code></pre>
  <p><strong>and here is the code I am trying to run (main.cpp) -</strong></p>
  <pre><code>#include &lt;stdio.h&gt;  
   #include &lt;stdint.h&gt;
  #include &lt;cstdint&gt;
  #include &lt;sys/types.h&gt;
  
  #include &lt;jdbc/cppconn/driver.h&gt;
  #include &lt;jdbc/cppconn/exception.h&gt;
  #include &lt;jdbc/cppconn/resultset.h&gt;
  #include &lt;jdbc/cppconn/statement.h&gt;
  #include &lt;jdbc/cppconn/prepared_statement.h&gt;
  //#include &lt;mysql/mysql.h&gt;
  
  
  int main()
  {
      try
          {
              sql::Driver *driver;
              sql::Connection *con;
              //sql::Statement *stmt;
              sql::ResultSet *res;
              sql::PreparedStatement *pstmt;
  
              /* Create a connection */
              driver = get_driver_instance();
          
      } catch (sql::SQLException &amp;e)
          {
              ///nav implementēts vairāk info
              //cout &lt;&lt; &quot;# ERR: SQLException in &quot; &lt;&lt; __FILE__;
              //cout &lt;&lt; &quot;(&quot; &lt;&lt; __FUNCTION__ &lt;&lt; &quot;) on line &quot; &lt;&lt; __LINE__ &lt;&lt; endl;
              /* what() (derived from std::runtime_error) fetches error message */
              //cout &lt;&lt; &quot;# ERR: &quot; &lt;&lt; e.what();
              //cout &lt;&lt; &quot; (MySQL error code: &quot; &lt;&lt; e.getErrorCode();
              //cout &lt;&lt; &quot;# ERR: SQLException in &quot; &lt;&lt; endl;
          }
      return 0;
  }
  </code></pre>
  <p><strong>I am using GNU make to compile it, and I get following error -</strong></p>
  <pre><code>C:\Users\FL\Desktop\TEST2&gt;make
  [ 50%] Building CXX object CMakeFiles/test.dir/main.cpp.obj
  In file included from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/resultse
  t.h:36:0,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:8:
  C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/config.h:101:19: error: confli
  cting declaration 'typedef long int int32_t'
   typedef __int32   int32_t;
                     ^~~~~~~
  In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_trait
  s.h:420,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:40,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\stdexcept:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\array:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\tuple:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_map.h:
  63,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\map:61,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/connecti
  on.h:36,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/driver.h
  :36,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:6:
  c:\mingw\include\stdint.h:62:15: note: previous declaration as 'typedef int int3
  2_t'
   typedef int   int32_t;
                 ^~~~~~~
  In file included from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/resultse
  t.h:36:0,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:8:
  C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/config.h:105:26: error: confli
  cting declaration 'typedef long unsigned int uint32_t'
   typedef unsigned __int32 uint32_t;
                            ^~~~~~~~
  In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_trait
  s.h:420,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:40,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\stdexcept:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\array:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\tuple:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_map.h:
  63,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\map:61,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/connecti
  on.h:36,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/driver.h
  :36,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:6:
  c:\mingw\include\stdint.h:63:19: note: previous declaration as 'typedef unsigned
   int uint32_t'
   typedef unsigned  uint32_t;
                     ^~~~~~~~
  In file included from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/statemen
  t.h:36:0,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:9:
  C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/config.h:101:19: error: confli
  cting declaration 'typedef long int int32_t'
   typedef __int32   int32_t;
                     ^~~~~~~
  In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_trait
  s.h:420,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:40,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\stdexcept:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\array:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\tuple:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_map.h:
  63,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\map:61,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/connecti
  on.h:36,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/driver.h
  :36,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:6:
  c:\mingw\include\stdint.h:62:15: note: previous declaration as 'typedef int int3
  2_t'
   typedef int   int32_t;
                 ^~~~~~~
  In file included from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/statemen
  t.h:36:0,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:9:
  C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/config.h:105:26: error: confli
  cting declaration 'typedef long unsigned int uint32_t'
   typedef unsigned __int32 uint32_t;
                            ^~~~~~~~
  In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_trait
  s.h:420,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:40,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\stdexcept:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\array:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\tuple:39,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_map.h:
  63,
                   from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\map:61,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/connecti
  on.h:36,
                   from C:/PROGRA~1/MySQL/MYSQLC~1.0/include/jdbc/cppconn/driver.h
  :36,
                   from C:\Users\FL\Desktop\TEST2\main.cpp:6:
  c:\mingw\include\stdint.h:63:19: note: previous declaration as 'typedef unsigned
   int uint32_t'
   typedef unsigned  uint32_t;
                     ^~~~~~~~
  make[2]: *** [CMakeFiles/test.dir/main.cpp.obj] Error 1
  make[1]: *** [CMakeFiles/test.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  <p>This means something is wrong with ether gcc or g++, right? or should I be using make from mingw installation directory instead of make from other directory?</p>
  <pre><code>C:\Users\FL&gt;make --version
  GNU Make 3.81
  Copyright (C) 2006  Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.
  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE.
  
  This program built for i386-pc-mingw32
  </code></pre>
  <p><strong>UPDATE: WITH ALL THE CHANGES ERROR NOW IS:</strong></p>
  <pre><code>[ 50%] Building CXX object CMakeFiles/test.dir/main.cpp.obj
  [100%] Linking CXX executable test.exe
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x22):
  ndefined reference to `check(std::__cxx11::basic_string&lt;char, std::char_traits&lt;
  har&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x76):
  ndefined reference to `check(std::map&lt;std::__cxx11::basic_string&lt;char, std::cha
  _traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::__cxx11::basic_string&lt;char, std::ch
  r_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;ch
  r, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;s
  d::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; c
  nst, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;ch
  r&gt; &gt; &gt; &gt; &gt; const&amp;)'
  collect2.exe: error: ld returned 1 exit status
  make[2]: *** [CMakeFiles\test.dir\build.make:100: test.exe] Error 1
  make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/test.dir/all] Error 2
  make: *** [Makefile:90: all] Error 2```
  </code></pre>
  <p><strong>SO MAYBE MINGW DOES NOT WORK WITH CONNECTOR PRECOMPILED BUT ONLY COMPILED WITH SAME COMPILER, SO:</strong></p>
  <p>SO WHAT I DID FIRST WAS downloading mysql connector 8.0 pre-compiled for windows from <a href="https://dev.mysql.com/downloads/connector/cpp/" rel="nofollow noreferrer">https://dev.mysql.com/downloads/connector/cpp/</a>
  installed it on C:\connector</p>
  <p>and then I thought maybe it just don't work with MINGW &quot;compiler&quot; at all so I found this article <a href="https://forums.mysql.com/read.php?117,426293,426927" rel="nofollow noreferrer">https://forums.mysql.com/read.php?117,426293,426927</a></p>
  <p>I downloaded source for it on <a href="https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-source-distribution.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-source-distribution.html</a></p>
  <p>and compiling using cmake I got this error and did not get to makefiles that are needed to use &quot;make&quot; command -</p>
  <pre><code>The C compiler identification is GNU 9.2.0
  The CXX compiler identification is GNU 9.2.0
  Detecting C compiler ABI info
  Detecting C compiler ABI info - done
  Check for working C compiler: C:/MinGW/bin/gcc.exe - skipped
  Detecting C compile features
  Detecting C compile features - done
  Detecting CXX compiler ABI info
  Detecting CXX compiler ABI info - done
  Check for working CXX compiler: C:/MinGW/bin/g++.exe - skipped
  Detecting CXX compile features
  Detecting CXX compile features - done
  BIG_ENDIAN: 0
  Building version 8.0.24
  Building on system: Windows-6.1.7601 (AMD64)
  Using cmake generator: MinGW Makefiles
  Using toolset: 
  Building 64bit code
  Building shared connector library
  Configuring CDK as part of MySQL_CONCPP project
  Looking for SSL library.
  CMake Error at cdk/cmake/DepFindSSL.cmake:79 (message):
    Cannot find appropriate system libraries for SSL.  Make sure you've
    specified a supported SSL version.  Consult the documentation for WITH_SSL
    alternatives
  Call Stack (most recent call first):
    cdk/cmake/DepFindSSL.cmake:354 (main)
    cdk/cmake/dependency.cmake:42 (include)
    cdk/CMakeLists.txt:96 (find_dependency)
  
  
  Setting up Protobuf.
  ==== Configuring Protobuf build using cmake generator: MinGW Makefiles   -DCMAKE_SYSTEM_NAME=Windows;-DCMAKE_SYSTEM_VERSION=6.1.7601
  CMake Deprecation Warning at CMakeLists.txt:44 (cmake_minimum_required):
  
    Compatibility with CMake &lt; 2.8.12 will be removed from a future version of
  
    CMake.
  
  
  
    Update the VERSION argument &lt;min&gt; value or use a ...&lt;max&gt; suffix to tell
  
    CMake that the project does not need compatibility with older versions.
  
  
  
  
  
  -- The C compiler identification is GNU 9.2.0
  
  -- The CXX compiler identification is GNU 9.2.0
  
  -- Detecting C compiler ABI info
  
  -- Detecting C compiler ABI info - done
  
  -- Check for working C compiler: C:/MinGW/bin/gcc.exe - skipped
  
  -- Detecting C compile features
  
  -- Detecting C compile features - done
  
  -- Detecting CXX compiler ABI info
  
  -- Detecting CXX compiler ABI info - done
  
  -- Check for working CXX compiler: C:/MinGW/bin/g++.exe - skipped
  
  -- Detecting CXX compile features
  
  -- Detecting CXX compile features - done
  
  -- BIG_ENDIAN: 0
  
  -- Looking for pthread.h
  
  -- Looking for pthread.h - found
  
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
  
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
  
  -- Found Threads: TRUE  
  
  Using pthreads for protobuf code
  
  
  -- Configuring done
  
  -- Generating done
  
  -- Build files have been written to: C:/Users/FL/Desktop/mysql-connector-cpp/cdk/protobuf
  
  ==== Protobuf build configured.
  Processor Count: 1
  Setting up RapidJSON.
  Skipping second declaration of config option: THROW_AS_ASSERT (found in: C:/Users/FL/Desktop/mysql-connector-cpp/cdk/CMakeLists.txt)
  Performing Test HAVE_STATIC_ASSERT
  Performing Test HAVE_STATIC_ASSERT - Success
  Performing Test HAVE_IS_SAME
  Performing Test HAVE_IS_SAME - Failed
  CMake Deprecation Warning at cdk/extra/zlib/CMakeLists.txt:24 (cmake_minimum_required):
    Compatibility with CMake &lt; 2.8.12 will be removed from a future version of
    CMake.
  
    Update the VERSION argument &lt;min&gt; value or use a ...&lt;max&gt; suffix to tell
    CMake that the project does not need compatibility with older versions.
  
  
  CMake Deprecation Warning at cdk/extra/zlib/CMakeLists.txt:37 (CMAKE_POLICY):
    The OLD behavior for policy CMP0075 will be removed from a future version
    of CMake.
  
    The cmake-policies(7) manual explains that the OLD behaviors of all
    policies are deprecated and that a policy should be set to OLD only under
    specific short-term circumstances.  Projects should be ported to the NEW
    behavior and not rely on setting a policy to OLD.
  
  
  Looking for sys/types.h
  Looking for sys/types.h - found
  Looking for stdint.h
  Looking for stdint.h - found
  Looking for stddef.h
  Looking for stddef.h - found
  Check size of off64_t
  Check size of off64_t - done
  Looking for fseeko
  Looking for fseeko - found
  Looking for unistd.h
  Looking for unistd.h - found
  CMake Deprecation Warning at cdk/extra/zstd/CMakeLists.txt:11 (CMAKE_MINIMUM_REQUIRED):
    Compatibility with CMake &lt; 2.8.12 will be removed from a future version of
    CMake.
  
    Update the VERSION argument &lt;min&gt; value or use a ...&lt;max&gt; suffix to tell
    CMake that the project does not need compatibility with older versions.
  
  
  ZSTD_LEGACY_SUPPORT not defined!
  Performing Test HAVE_SHARED_PTR
  Performing Test HAVE_SHARED_PTR - Success
  Performing Test HAVE_SYSTEM_ERROR
  Performing Test HAVE_SYSTEM_ERROR - Success
  Check size of wchar_t
  Check size of wchar_t - done
  Looking for sys/endian.h
  Looking for sys/endian.h - not found
  Looking for sys/byteorder.h
  Looking for sys/byteorder.h - not found
  CMake Deprecation Warning at cdk/core/CMakeLists.txt:30 (cmake_minimum_required):
    Compatibility with CMake &lt; 2.8.12 will be removed from a future version of
    CMake.
  
    Update the VERSION argument &lt;min&gt; value or use a ...&lt;max&gt; suffix to tell
    CMake that the project does not need compatibility with older versions.
  
  
  Wrote configuration header: C:/Users/FL/Desktop/mysql-connector-cpp/cdk/include/mysql/cdk/config.h
  Preparing to merge SHARED library: connector (xapi;devapi)
  Connector library name: mysqlcppconn8-2
  Building version 8.0.24
  Generating INFO_SRC
  Generating INFO_BIN
  Install location: C:/Users/FL/MySQL/MySQL Connector C++ 
  Connector libraries will be installed at: lib64
  
  Project configuration options:
  
  : BUILD_STATIC: OFF
  Build static version of connector library
  
  : WITH_SSL: system
  Either 'system' to use system-wide OpenSSL library, or custom OpenSSL location. (default : system)
  
  : WITH_JDBC: OFF
  Whether to build a variant of connector library which implements legacy JDBC API
  
  Configuring incomplete, errors occurred!
  See also &quot;C:/Users/FL/Desktop/mysql-connector-cpp/CMakeFiles/CMakeOutput.log&quot;.
  See also &quot;C:/Users/FL/Desktop/mysql-connector-cpp/CMakeFiles/CMakeError.log&quot;.
  </code></pre>
  <p>** BIT LATEEERRR ****</p>
  <p><strong>OKAAAAAAY SO I'M TRYING TO COMPILE MARIADB <a href="https://mariadb.com/docs/clients/connector-cpp/" rel="nofollow noreferrer">https://mariadb.com/docs/clients/connector-cpp/</a> using MINGW with following cmakelists.txt config</strong></p>
  <pre><code>cmake_minimum_required(VERSION 3.16) # Or whatever version you use
  set(CMAKE_CXX_STANDARD 17)
  # THIS HAS TO COME BEFORE THE PROJECT LINE
  project(test VERSION 0.0.0 LANGUAGES C CXX)
  project(main)
  set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR &quot;C:\\mariaconnector&quot;)
  include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}\\include)
  add_executable(test main.cpp)
  target_compile_features(test PRIVATE cxx_range_for)  
  set(STDFS_LIB stdc++fs)
  </code></pre>
  <p>my code is:</p>
  <pre><code>#include &lt;stdio.h&gt;  
  #include &lt;stdint.h&gt;
  #include &lt;cstdint&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;iostream&gt;
  #include &lt;mariadb/conncpp.hpp&gt;
  
  //#include &lt;mysql/mysql.h&gt;
  using std::uint32_t;
  
  // Function to print Contacts
  void printContacts(std::shared_ptr&lt;sql::Statement&gt; &amp;stmnt)
  {
     try
     {
        // Execute SELECT Statement
        std::unique_ptr&lt;sql::ResultSet&gt; res(
              stmnt-&gt;executeQuery(&quot;SELECT first_name, last_name, email FROM test.contacts&quot;)
           );
  
        // Loop over Result-set
        while (res-&gt;next())
        {
           // Retrieve Values and Print Contacts
           std::cout &lt;&lt; &quot;- &quot;
              &lt;&lt; res-&gt;getString(&quot;first_name&quot;)
              &lt;&lt; &quot; &quot;
              &lt;&lt; res-&gt;getString(&quot;last_name&quot;)
              &lt;&lt; &quot; &lt;&quot;
              &lt;&lt; res-&gt;getString(&quot;email&quot;)
              &lt;&lt; &quot;&gt;&quot;
              &lt;&lt; std::endl;
        }
     }
  
     // Catch Exception
     catch (sql::SQLException&amp; e)
     {
        std::cerr &lt;&lt; &quot;Error printing contacts: &quot;
           &lt;&lt; e.what() &lt;&lt; std::endl;
     }
  }
  
  // Main Process
  int main(int argc, char **argv)
  {
     try
     {
        // Instantiate Driver
        sql::Driver* driver = sql::mariadb::get_driver_instance();
  
        // Configure Connection
        // The URL or TCP connection string format is
        // ``jdbc:mariadb://host:port/database``.
        sql::SQLString url(&quot;jdbc:mariadb://192.0.2.1:3306/test&quot;);
  
        // Use a properties map for the user name and password
        sql::Properties properties({
              {&quot;user&quot;, &quot;db_user&quot;},
              {&quot;password&quot;, &quot;db_user_password&quot;}
           });
  
        // Establish Connection
        // Use a smart pointer for extra safety
        std::unique_ptr&lt;sql::Connection&gt; conn(driver-&gt;connect(url, properties));
  
        // Create a Statement
        // Use a smart pointer for extra safety
        std::shared_ptr&lt;sql::Statement&gt; stmnt(conn-&gt;createStatement());
  
        printContacts(stmnt);
  
        // Close Connection
        conn-&gt;close();
     }
  
     // Catch Exceptions
     catch (sql::SQLException &amp;e)
     {
        std::cerr &lt;&lt; &quot;Error Connecting to MariaDB Platform: &quot;
           &lt;&lt; e.what() &lt;&lt; std::endl;
  
        // Exit (Failed)
        return 1;
     }
  
     // Exit (Success)
     return 0;
  }
  </code></pre>
  <p>I get this error-</p>
  <pre><code>C:\Users\FL\Desktop\testMARIA&gt;make
  [ 50%] Building CXX object CMakeFiles/test.dir/main.cpp.obj
  [100%] Linking CXX executable test.exe
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xd4):
  ndefined reference to `__imp__ZN3sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xff):
  ndefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x16a):
  undefined reference to `__imp__ZN3sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x190):
  undefined reference to `__imp__ZN3sqllsERSoRKNS_9SQLStringE'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1d4):
  undefined reference to `__imp__ZN3sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1fa):
  undefined reference to `__imp__ZN3sqllsERSoRKNS_9SQLStringE'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x23e):
  undefined reference to `__imp__ZN3sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x264):
  undefined reference to `__imp__ZN3sqllsERSoRKNS_9SQLStringE'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x292):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2a2):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2b2):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2c2):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2d2):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2e2):
  more undefined references to `__imp__ZN3sql9SQLStringD1Ev' follow
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x470):
  undefined reference to `__imp__ZN3sql7mariadb19get_driver_instanceEv'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x48a):
  undefined reference to `__imp__ZN3sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x5e3):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x67f):
  undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_ED1Ev[_ZNSt4pairIKN3sql9SQLStringES1_ED1Ev]+0x1a): undef
  ned reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_ED1Ev[_ZNSt4pairIKN3sql9SQLStringES1_ED1Ev]+0x2a): undef
  ned reference to `__imp__ZN3sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1IRA5_KcRA8_S5_Lb1EEEOT_OT0_[_ZNSt4pairIKN3sql9SQLStri
  gES1_EC1IRA5_KcRA8_S5_Lb1EEEOT_OT0_]+0x33): undefined reference to `__imp__ZN3s
  l9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1IRA5_KcRA8_S5_Lb1EEEOT_OT0_[_ZNSt4pairIKN3sql9SQLStri
  gES1_EC1IRA5_KcRA8_S5_Lb1EEEOT_OT0_]+0x56): undefined reference to `__imp__ZN3s
  l9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1IRA5_KcRA8_S5_Lb1EEEOT_OT0_[_ZNSt4pairIKN3sql9SQLStri
  gES1_EC1IRA5_KcRA8_S5_Lb1EEEOT_OT0_]+0x6b): undefined reference to `__imp__ZN3s
  l9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1IRA9_KcRA17_S5_Lb1EEEOT_OT0_[_ZNSt4pairIKN3sql9SQLStr
  ngES1_EC1IRA9_KcRA17_S5_Lb1EEEOT_OT0_]+0x33): undefined reference to `__imp__ZN
  sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1IRA9_KcRA17_S5_Lb1EEEOT_OT0_[_ZNSt4pairIKN3sql9SQLStr
  ngES1_EC1IRA9_KcRA17_S5_Lb1EEEOT_OT0_]+0x56): undefined reference to `__imp__ZN
  sql9SQLStringC1EPKc'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1IRA9_KcRA17_S5_Lb1EEEOT_OT0_[_ZNSt4pairIKN3sql9SQLStr
  ngES1_EC1IRA9_KcRA17_S5_Lb1EEEOT_OT0_]+0x6b): undefined reference to `__imp__ZN
  sql9SQLStringD1Ev'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNKSt4
  essIN3sql9SQLStringEEclERKS1_S4_[_ZNKSt4lessIN3sql9SQLStringEEclERKS1_S4_]+0x22
  : undefined reference to `__imp__ZNK3sql9SQLStringltERKS0_'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1ERKS3_[_ZNSt4pairIKN3sql9SQLStringES1_EC1ERKS3_]+0x24
  : undefined reference to `__imp__ZN3sql9SQLStringC1ERKS0_'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1ERKS3_[_ZNSt4pairIKN3sql9SQLStringES1_EC1ERKS3_]+0x40
  : undefined reference to `__imp__ZN3sql9SQLStringC1ERKS0_'
  c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32
  bin/ld.exe: CMakeFiles\test.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNSt4p
  irIKN3sql9SQLStringES1_EC1ERKS3_[_ZNSt4pairIKN3sql9SQLStringES1_EC1ERKS3_]+0x55
  : undefined reference to `__imp__ZN3sql9SQLStringD1Ev'
  collect2.exe: error: ld returned 1 exit status
  make[2]: *** [CMakeFiles\test.dir\build.make:99: test.exe] Error 1
  make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/test.dir/all] Error 2
  make: *** [Makefile:90: all] Error 2
  </code></pre>
  <p>:&gt;</p>