windows下C API连接mysql问题 满意加高分 急急!!
怎么在windows下用VC6.0工具连接mysql,我现在不需要代码,只想知道怎么加载libmySQL.dll步骤是什么??我用LoadLibrary("libmySQ...
怎么在windows下 用VC 6.0工具连接mysql, 我现在不需要代码,只想知道怎么加载libmySQL.dll
步骤是什么??我用LoadLibrary("libmySQL.dll");加载报错:
E:\BT_SRC\demo\demo.cpp(5) : error C2501: 'LoadLibraryA' : missing storage-class or type specifiers
E:\BT_SRC\demo\demo.cpp(5) : error C2373: 'LoadLibraryA' : redefinition; different type modifiers
c:\program files\microsoft visual studio\vc98\include\winbase.h(4159) : see declaration of 'LoadLibraryA'
E:\BT_SRC\demo\demo.cpp(5) : error C2440: 'initializing' : cannot convert from 'char [13]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
用这个#pragma comment(lib, "libmysql.dll")加载,将libmysql.dll拷贝到当前工程目录报错:
ibmysql.dll : warning LNK4003: invalid library format; library ignored
libmysql.dll : warning LNK4003: invalid library format; library ignored
demo.obj : error LNK2001: unresolved external symbol _mysql_free_result@4
demo.obj : error LNK2001: unresolved external symbol _mysql_num_fields@4
demo.obj : error LNK2001: unresolved external symbol _mysql_fetch_row@4
demo.obj : error LNK2001: unresolved external symbol _mysql_num_rows@4
demo.obj : error LNK2001: unresolved external symbol _mysql_store_result@4
demo.obj : error LNK2001: unresolved external symbol _mysql_query@8
demo.obj : error LNK2001: unresolved external symbol _mysql_real_connect@32
demo.obj : error LNK2001: unresolved external symbol _mysql_init@4
注:我完整的安装了mysql 5.1
满意一定高分!!! 展开
步骤是什么??我用LoadLibrary("libmySQL.dll");加载报错:
E:\BT_SRC\demo\demo.cpp(5) : error C2501: 'LoadLibraryA' : missing storage-class or type specifiers
E:\BT_SRC\demo\demo.cpp(5) : error C2373: 'LoadLibraryA' : redefinition; different type modifiers
c:\program files\microsoft visual studio\vc98\include\winbase.h(4159) : see declaration of 'LoadLibraryA'
E:\BT_SRC\demo\demo.cpp(5) : error C2440: 'initializing' : cannot convert from 'char [13]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
用这个#pragma comment(lib, "libmysql.dll")加载,将libmysql.dll拷贝到当前工程目录报错:
ibmysql.dll : warning LNK4003: invalid library format; library ignored
libmysql.dll : warning LNK4003: invalid library format; library ignored
demo.obj : error LNK2001: unresolved external symbol _mysql_free_result@4
demo.obj : error LNK2001: unresolved external symbol _mysql_num_fields@4
demo.obj : error LNK2001: unresolved external symbol _mysql_fetch_row@4
demo.obj : error LNK2001: unresolved external symbol _mysql_num_rows@4
demo.obj : error LNK2001: unresolved external symbol _mysql_store_result@4
demo.obj : error LNK2001: unresolved external symbol _mysql_query@8
demo.obj : error LNK2001: unresolved external symbol _mysql_real_connect@32
demo.obj : error LNK2001: unresolved external symbol _mysql_init@4
注:我完整的安装了mysql 5.1
满意一定高分!!! 展开
展开全部
#include <windows.h>
#include "C:/MySQL Server 5.1/include/mysql.h"
#pragma comment(lib, "C:/MySQL Server 5.1/lib/debug/libmysql.lib")
这样就行了
#include "C:/MySQL Server 5.1/include/mysql.h"
#pragma comment(lib, "C:/MySQL Server 5.1/lib/debug/libmysql.lib")
这样就行了
更多追问追答
追问
我的路径是#include #include #include
#include "C:\Program Files\MySQL\MySQL Server 5.1\include\mysql.h"
#pragma comment(lib,"C:\Program Files\MySQL\MySQL Server 5.1\lib\debug\libmysql.dll")还是报错:
LINK : fatal error LNK1104: cannot open file "C:Program FilesMySQLMySQL Server 5.1libdebuglibmysql.dll"
Error executing link.exe.
不能打开??? 大侠指教啊!!!
追答
用/或\\
是libmysql.lib,不要指定dll
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询