如何将 mysqlcppconn.lib 链接到 C++ 项目 [英] How to link mysqlcppconn.lib to a c++ project

查看:34
本文介绍了如何将 mysqlcppconn.lib 链接到 C++ 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 C++ 项目中使用 mysqlcppconn.lib.但是,当我使用库中的功能时,出现错误:

 Severity Code 描述 Project File Line Suppression State函数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);

我已经尝试了 32 位和 64 位版本的库,但都给出了相同的错误.我不确定是否需要在可执行目录中放入一些 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(属性->链接器->常规->附加库目录)

3、将.lib文件名及其扩展名添加到Additional Dependencies(属性->链接器->输入->附加依赖项)

我建议您可以尝试检查文件是否在您指定的位置,或者您是否提供了正确的库路径.你不能混合 32 位和 64 位.请确保您将 64 位库与 64 位应用程序链接,或者将您的应用更改为 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.

这篇关于如何将 mysqlcppconn.lib 链接到 C++ 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆