Static linking of MySQL in C/C++(C/C++ 中 MySQL 的静态链接)
问题描述
我正在尝试使用 C++ 开发一个使用 MySQL 的应用程序.我从他们的网站下载了该库,并尝试编译以下代码:
I am trying to develop an application that uses MySQL using C++. I downloaded the library from their website and I have attempted to compile the following code:
#include <iostream>
#include <windows.h>
#include <mysql.h>
using namespace std;
int main()
{
MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
mysql_init(&mysql);
}
具有 mysql_init(&mysql);
的那行给了我一个编译错误
The line that has mysql_init(&mysql);
gives me a compilation error
undefined reference to `mysql_init@4'
我猜这是由于库错误.我按顺序链接 mysqlclient.lib
和 libmysql.lib
.我需要做什么才能在不需要 dll 文件的情况下进行编译?那可能吗?谢谢你.注意:我在 Windows 7 x64 上使用 mingw32 为 Windows 开发应用程序.
I am guessing this is due to a library error. I am linking mysqlclient.lib
and libmysql.lib
in that order. What do I need to do to make this compile without requiring a dll file? Is that possible? Thank you.
Note: I am using mingw32 on Windows 7 x64 to develop an application for Windows.
推荐答案
也许这个链接会有所帮助.它指出 mysqlclient.lib 是静态库,而 libmysql.lib 是动态库,所以我认为您不应该同时链接两者.
Maybe this link will help. It states that mysqlclient.lib is the static library and libmysql.lib is the dynamic library, so I don't think you should be linking both.
http://dev.mysql.com/doc/refman/5.0/en/building-clients.html
这篇关于C/C++ 中 MySQL 的静态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C/C++ 中 MySQL 的静态链接


- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01