Libs and linker with CMake and MySQL C++ Connector?

霸气de小男生 提交于 2021-02-11 06:01:17

问题


I download the MySQL C++ Connector, I need it for a project in CLion, now, I was trying to make it run, but it was all in vain, I get the error -1073741515 (0xC0000135), i've read that is about a linking or lib problem.

My current CMake:

cmake_minimum_required(VERSION 3.6)
project(Entrenamiento CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "-Wall")
set(SOURCE_FILES main.cpp)
set(Entrenamiento_VERSION_MAJOR 1)
set(Entrenamiento_VERSION_MINOR 0)
add_library(mysqlcppconn SHARED IMPORTED)
set_target_properties(
    mysqlcppconn
    PROPERTIES LINKER_LANGUAGE CXX
    IMPORTED_LOCATION "C:/MinGW/x86_64-w64-mingw32/lib/opt/mysqlcppconn.dll"
    IMPORTED_IMPLIB "C:/MinGW/x86_64-w64-mingw32/lib/opt/mysqlcppconn.lib")
link_directories("C:/MinGW/x86_64-w64-mingw32/lib/opt")
add_executable(Entrenamiento ${SOURCE_FILES})
target_link_libraries(Entrenamiento mysqlcppconn)

My code is this:

#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

int main() {
   try {
        sql::Driver *driver;
        sql::Connection *con;
        sql::Statement *stmt;
        sql::ResultSet *res;
        driver = get_driver_instance();  //HERE IS THE ERROR

    } catch (sql::SQLException &e) {
        std::cout<<e.what()<<std::endl;
    }
    return EXIT_SUCCESS;
}

and this is the error:

Process finished with exit code -1073741515 (0xC0000135)

来源:https://stackoverflow.com/questions/42265014/libs-and-linker-with-cmake-and-mysql-c-connector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!