問題描述
我正在嘗試在我的 C++ 項目中使用 mysqlcppconn.lib.但是,當(dāng)我使用庫中的功能時,出現(xiàn)錯誤:
Severity Code 描述 Project File Line Suppression State函數(shù)public: void __thiscall Achievement::set(void)"中引用的錯誤LNK2019未解析的外部符號_mysql_init@4(?set@Achievement@@QAEXXZ) 僵尸 C:\Users\jorda\OneDrive - Limerick Institute of Technology\College\Final Year Project\Achievement_Libary\Copy - Copy\zombie\Achievement.obj 1
我正在使用的代碼:
MYSQL* conn;MYSQL_ROW 行;MYSQL_RES* 資源;conn = mysql_init(0);
錯誤似乎來自mysql_init(0);
我已經(jīng)嘗試了 32 位和 64 位版本的庫,但都給出了相同的錯誤.我不確定是否需要在可執(zhí)行目錄中放入一些 dll.我試過把 libssl-1_1.dll &libcrypto-1_1.dll 來自 32 位和 64 位文件,因為這是一個教程所做的,但是這不起作用.
有人知道在 Visual Studio 項目中嘗試使用 C++ 連接器的過程嗎?任何幫助表示贊賞.這是鏈接器的庫和輸入路徑
<塊引用>有人知道在 Visual Studio 項目中嘗試使用 C++ 連接器的過程嗎?
我建議您可以嘗試以下步驟:
1、將頭文件的路徑添加到Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)
2、將.lib文件的路徑添加到Additional Library Directories(屬性->鏈接器->常規(guī)->附加庫目錄)
3、將.lib文件名及其擴(kuò)展名添加到Additional Dependencies(屬性->鏈接器->輸入->附加依賴項)
我建議您可以嘗試檢查文件是否在您指定的位置,或者您是否提供了正確的庫路徑.你不能混合 32 位和 64 位.請確保您將 64 位庫與 64 位應(yīng)用程序鏈接,或者將您的應(yīng)用更改為 32 位并與 32 位庫鏈接.
I'm trying to use the mysqlcppconn.lib in my c++ project. However, when I put use functionality from the library I get an error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _mysql_init@4 referenced in function "public: void __thiscall Achievement::set(void)" (?set@Achievement@@QAEXXZ) zombie C:\Users\jorda\OneDrive - Limerick Institute Of Technology\College\Final Year Project\Achievement_Libary\Copy - Copy\zombie\Achievement.obj 1
The code I'm using:
MYSQL* conn;
MYSQL_ROW row;
MYSQL_RES* res;
conn = mysql_init(0);
The errors seems to come from the mysql_init(0);
I've tried both the 32 and 64-bit version of the library but both give the same error. I'm not sure if I need to put some dlls inside the executable directory. I've tried putting libssl-1_1.dll & libcrypto-1_1.dll from both the 32 bit and 64-bit files as that's what one tutorial did however this did not work.
Would anyone know the process of trying to use the C++ connector in a visual studio project? Any help is appreciated. Here are the lib and input paths from the Linker
Would anyone know the process of trying to use the C++ connector in a visual studio project?
I suggest you could try the following steps:
1,Add the path to the header file to the Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)
2,Add the path to the .lib file to the Additional Library Directories (property -> linker -> General -> Additional Library Directories)
3,Add the name of the .lib file with its extension to Additional Dependencies (property -> linker -> input -> Additional Dependencies)
I suggest you could try to check if the file is in the location that you specified, or if you have provided the correct library path. And you couldn't mix 32 bit and 64 bit. Please make sure you're linking in 64-bit libraries with the 64-bit application, or change your app to 32-bit and link with the 32-bit libraries.
這篇關(guān)于如何將 mysqlcppconn.lib 鏈接到 C++ 項目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!