向下滚动查找我找到的解决方案(部分):
我正在使用 Windows 8.1,64位笔记本电脑 这是我第一次尝试使用上面提到的连接器将C ++连接到MySQL。 错误如下:
Error 1 error LNK2019: unresolved external symbol "class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_driver_instance(void)" (?get_driver_instance@mysql@sql@@YAPAVMySQL_Driver@12@XZ) referenced in function _main C:\Users\user\documents\visual studio 2013\Projects\Profile\Profile\Profile.obj Profile
这是我的主要代码:
// Profile.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <string>
#include "mysql_connection.h"
#include "mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#define dbHOST "tcp://127.0.0.1:3306"
#define dbUSER "root"
#define dbPASS "root"
#define dbDB "db_test"
using namespace std;
using namespace sql;
int main()
{
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
driver = sql::mysql::get_driver_instance();
con = driver->connect(dbHOST, dbUSER, dbPASS);
delete con;
system("pause");
return 0;
}
我已按照this mysql site的说明进行静态安装。
我还有很多关于错误的Google。 有人建议它可能是64位和32位不同的连接器文件 - 我尝试下载它们(它们安装在程序文件和程序文件(x86)中,但错误仍然存在。
有一点需要注意,当我将它与32位连接器文件链接起来时,会产生更多错误。
让我惊讶的是,在所有搜索之后,到目前为止,VS Express 2013是否与MySQL连接不兼容? 我听说ppl说使用Qt会更容易,但我还是想尝试一下。
如果我的问题含糊不清或需要更多信息,请告诉我。 提前谢谢!
我发现的解决方案
我不想将其添加为答案,因为它无法解决我提出的问题。
无论如何,我发现link which gives fairly simple instructions已经让它发挥作用。如果有人愿意调查我的原始问题,仍然会感激。
:)