MariaDB社区

标题: 无法定位程序输入点mysql_set_character_set于动态连接库LIBMYSQL.dll上 [打印本页]

作者: 171128203    时间: 2009-4-12 11:32
标题: 无法定位程序输入点mysql_set_character_set于动态连接库LIBMYSQL.dll上
这是我在网上随便下的一段demo
#include <windows.h>
#include <process.h>
#include <iostream>
#include <string>
#include "mysql.h"   //安装的mysql的头文件所在的位置
using namespace std;
string host="localhost";
string user="root";
string pwd="";
string dbname="pure";
string sql="select * from cdn";
unsigned int port=3306;
int status;
int main(){
MYSQL *mysql;
mysql=mysql_init(0);
MYSQL_RES *result;
MYSQL_ROW row;
if(mysql_real_connect(mysql,host.c_str(),user.c_str(),pwd.c_str(),dbname.c_str(),port,NULL,CLIENT_FOUND_ROWS)==NULL){
  cout << "connect failure!" << endl;
  return EXIT_FAILURE;
}else{
  cout << "connect success!" << endl;
}
mysql_set_character_set(mysql,"gbk");
status=mysql_query(mysql,sql.c_str());
if(status !=0 ){
  cout << "query failure!" << endl;
}
cout << "the status is :" << status << endl;
result=mysql_store_result(mysql);
while(row=mysql_fetch_row(result)){
  cout << row[1] <<"|"<< row[2] << endl;
}
mysql_free_result(result);
mysql_close(mysql);
}

我安装的是mysql-essential-5.1.33-win32
开发环境是VS2008
库文件什么的都配置好了
编译通过
运行的时候就出现错误:无法定位程序输入点mysql_set_character_set于动态连接库LIBMYSQL.dll上
请大家帮帮忙
我是要准备做一个对MYSQL的C API的封装类,想先测试下,可是上述问题解决不了,测试不了........

PS:我是新手
作者: kider    时间: 2009-4-12 21:29
检查下环境变量

关注中...
作者: 171128203    时间: 2009-4-13 20:18
没人知道是什么问题吗?
作者: 171128203    时间: 2009-4-13 21:15
问题终于解决了,原来是我的LIBMYSQL.dll的版本不对,安装了MYSQL后,把在bin目录下的LIBMYSQL.dll复制到system32里就可以了..............
作者: kider    时间: 2009-4-14 14:29

作者: yk20000    时间: 2010-4-15 10:19
在 工程属性->链接器->输入中添加libmysql.lib , 估计可以解决你的问题,注意好运!因为你的工程不知道怎样去和libmysql.dll发生关联




欢迎光临 MariaDB社区 (http://123.56.88.72/) Powered by Discuz! X3.2