C++ mysql 仅在构建解决方案时LNK2019错误
C++ mysql LNK2019 errors only while building solution
Error LNK1120 6 unresolved externals
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::~SQLString(void)" (__imp_??1SQLString@sql@@QAE@XZ) referenced in function _main
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::SQLString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0SQLString@sql@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::SQLString(char const * const)" (__imp_??0SQLString@sql@@QAE@QBD@Z) referenced in function _main
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::operator class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &(void)const " (__imp_??BSQLString@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _main
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __thiscall sql::SQLString::asStdString(void)const " (__imp_?asStdString@SQLString@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "bool __cdecl sql::operator!=(class sql::SQLString const &,class sql::SQLString const &)" (??9sql@@YA_NABVSQLString@0@0@Z)
Error LNK2019 unresolved external symbol __imp__get_driver_instance referenced in function _main
这仅在构建项目未编译时发生
我已经四处寻找解决方案,只是找不到一个尝试过不同库的库,都出现了这个问题
#include "driver/mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
int main()
{
string Username;
string Pass;
try {
sql::ResultSet *res;
sql::ResultSet *res2;
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
bool loggingin = true;
driver = get_driver_instance();
//place holder text not actualy there
con = driver->connect("[host]", "[username]", "[password]");
con->setSchema("Information");
stmt = con->createStatement();
res = stmt->executeQuery("Get Password where Username = '" + Username + "'");
res2 = stmt->executeQuery("Get HWID where Username = '" + Username + "'");
while (loggingin) {
printf("Please Type Your Username: n >>");
cin >> Username;
printf("Please Type Your Password: n >>");
cin >> Pass;
res = stmt->executeQuery("Get Password where Username = '" + Username + "'");
string password = res->getString(1);
;
while (res->next()) {
if (res->getRow() == 0 || password != Pass) {
printf("Username or Password Wrong");
}
else {
if (res2->getString(1) != getHWID()) {
exit(1);
}
else {
loggingin = false;
}
}
break;
}
}
delete con;
delete res;
delete res2;
delete stmt;
}
catch (sql::SQLException &e) {
system("cls");
printf("please reload");
while (true) {
Sleep(1);
}
}
我只是想让它构建,没有其他问题,只是它无法构建
通过将mysqlcppconn.lib和mysqlcppconn-static.lib添加到Linker>Input>extra Dependancy来修复
相关文章:
- 链接CPP文件进行测试时发生LNK2019错误
- 32位到64位:LNK2019错误,如何检索相关信息
- 在结构函数之间传递文件路径 C++ 编辑:修复LNK2019错误
- 尝试使用 TMXlite 编译项目时LNK2019错误
- LNK2019错误;此处缺少/未定义的内容
- DX11 DirectInput8创建引起LNK2019错误
- C++ mysql 仅在构建解决方案时LNK2019错误
- C LNK2019错误,未解决的外部字符
- C++ 带有出现LNK2019错误的对象的链接列表
- 解决 main 中的LNK2019错误
- 尝试使用命名空间中的函数时LNK2019错误
- LNK2019错误未解析的外部符号
- LNK2019错误,在Visual Studio 2012 C++的main中使用的函数
- 同一项目中两个类之间的visual c++LNK2019错误
- LNK2019错误(未解析的外部符号)将SQLite链接到DLL
- C++/CLI 包装器LNK2028和LNK2019错误
- LNK2019错误,尝试覆盖运算符<< 对于 LinkedList 类
- LNK2001和LNK2019错误 - DirectX 未解析的外部符号
- (2012)Visual C++LNK2019错误,可能是模板问题
- LNK2019错误一个DLL链接到MFC DLL