Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL C++连接器未解决外部问题 我试图用Visual Studio 15 2017构建MySQL C++连接器应用程序,使用MySQL C++连接器作为静态库。然而,在仔细地遵循在中给出的说明之后,我得到了LNK2001错误未解决的外部符号_get_driver_实例_C++_Mysql_Visual Studio 2017 - Fatal编程技术网

MySQL C++连接器未解决外部问题 我试图用Visual Studio 15 2017构建MySQL C++连接器应用程序,使用MySQL C++连接器作为静态库。然而,在仔细地遵循在中给出的说明之后,我得到了LNK2001错误未解决的外部符号_get_driver_实例

MySQL C++连接器未解决外部问题 我试图用Visual Studio 15 2017构建MySQL C++连接器应用程序,使用MySQL C++连接器作为静态库。然而,在仔细地遵循在中给出的说明之后,我得到了LNK2001错误未解决的外部符号_get_driver_实例,c++,mysql,visual-studio-2017,C++,Mysql,Visual Studio 2017,以上图片显示了所需的库设置和我根据上述链接设置的其他设置 我试图构建的代码是: /* Standard C++ includes */ #include <stdlib.h> #include <iostream> /* Include directly the different headers from cppconn/ and mysql_driver.h + mysql_util.h (and mysql_connection.h). This will red

以上图片显示了所需的库设置和我根据上述链接设置的其他设置

我试图构建的代码是:

/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>

/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "mysql_connection.h"

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int main(void)
{
    try {
    sql::Driver *driver;
    sql::Connection *con;
    sql::Statement *stmt;
    sql::ResultSet *res;

    /* 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");

    stmt = con->createStatement();
    res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
    while (res->next()) {
        cout << "\t... MySQL replies: ";
        /* Access column data by alias or column name */
        cout << res->getString("_message") << endl;
        cout << "\t... MySQL says it again: ";
        /* Access column data by numeric offset, 1 is the first column */
        cout << res->getString(1) << endl;
    }
    delete res;
    delete stmt;
    delete con;

    }
    catch (sql::SQLException &e) {
        cout << "# ERR: SQLException in " << __FILE__;
        cout << "(" << __FUNCTION__ << ") on line " 
            << __LINE__ << endl;
        cout << "# ERR: " << e.what();
        cout << " (MySQL error code: " << e.getErrorCode();
        cout << ", SQLState: " << e.getSQLState() << " )" << endl;
    }

    cout << endl;

    return EXIT_SUCCESS;
}
它来自MySQL示例脚本

我已尝试解决一些问题:

将项目平台从Win32更改为x64,并将解决方案平台从x86更改为x64,导致检测到“\u MSC\u VER”的错误LNK2038不匹配:值“1800”与值“1900”不匹配 键入库的完整路径名 从源代码构建connector/C++不起作用,但不确定是否正确。
我已经阅读了关于这个话题的大多数其他帖子,但是解决方案似乎不起作用。是否有针对Windows的解决方案?

由于空格的原因,请将路径放在引号中的设置中

"C:\Program Files\MySQL\Connector C++ 1.1\lib\opt";

"C:\Program Files\MySQL\Connector C++ 1.1\include";...

另外,请确保在“链接器->输入设置”部分列出了所需的所有库。

要在windows上使用MySQL连接器/c++而不从源代码生成,Visual Studio 2013必须与32位连接器/c++库一起使用。我必须专门下载32位库。

可能是重复的否,那篇文章是关于Linux的谢谢,我已经这样做了。它没有改变错误,但很高兴知道。我相信我的每个库都只需要链接一个,因为这是MySQL文档中提到的唯一一个。你也可以在库文件中搜索文本_get_driver_实例。find(find)get(u driver)instance*.lib将在命令行中工作命令从mysqlcppcconn-static.lib调出sql(u mysql)get(u driver)instance。