我正在尝试使用c程序访问本地主机上的mysql数据库。
然而,我得到一个错误,我认为是有关要么一个丢失的dll或一个丢失的.lib文件,但我不知道如何添加它们?
我正在使用mysql connector c8.0下载的文件/库。
具体来说,如何将.dll文件添加到我的项目中以阻止这些错误
请看下面我的当前代码!任何帮助或建议都会非常好,谢谢!
# include <iostream>
# 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)
{
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", "password");
/* 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;
}
我得到的错误是:
1>------ Build started: Project: AccessSQL_v1, Configuration: Debug x64 ------
1>accessSQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl sql::SQLString::~SQLString(void)" (__imp_??1SQLString@sql@@QEAA@XZ) referenced in function main
1>accessSQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl sql::SQLString::SQLString(char const * const)" (__imp_??0SQLString@sql@@QEAA@QEBD@Z) referenced in function main
1>accessSQL.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl sql::SQLString::asStdString(void)const " (__imp_?asStdString@SQLString@sql@@QEBAAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class sql::SQLString const &)" (??6std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBVSQLString@sql@@@Z)
1>accessSQL.obj : error LNK2019: unresolved external symbol __imp_get_driver_instance referenced in function main
1>C:\Users\LabPC\source\repos\AccessSQL_v1\x64\Debug\AccessSQL_v1.exe : fatal error LNK1120: 4 unresolved externals
1>Done building project "AccessSQL_v1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ```
暂无答案!
目前还没有任何答案,快来回答吧!