我下载了MySQL C ++连接器,我需要它用于CLion中的项目,现在,我试图让它运行,但这一切都是徒劳的,我得到错误-1073741515(0xC0000135),我读过这是关于链接或库问题。
我目前的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)
我的代码是:
#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;
}
这是错误:
Process finished with exit code -1073741515 (0xC0000135)