在C / C ++中静态链接MySQL [英] Static linking of MySQL in C/C++

查看:189
本文介绍了在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) ; 给我一个编译错误

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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