0

您好,当我尝试编译我的 MySQL 连接代码时,我收到了这些 LNK 错误

1>main.obj : error LNK2028: unresolved token (0A00027D) "extern "C" struct st_mysql * __stdcall mysql_init(struct st_mysql *)" (?mysql_init@@$$J14YGPAUst_mysql@@PAU1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>main.obj : error LNK2028: unresolved token (0A0002B9) "extern "C" struct st_mysql * __stdcall mysql_real_connect(struct st_mysql *,char const *,char const *,char const *,char const *,unsigned int,char const *,unsigned int)" (?mysql_real_connect@@$$J232YGPAUst_mysql@@PAU1@PBD111I1I@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>main.obj : error LNK2028: unresolved token (0A0002C8) "extern "C" int __stdcall mysql_query(struct st_mysql *,char const *)" (?mysql_query@@$$J18YGHPAUst_mysql@@PBD@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>main.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall mysql_query(struct st_mysql *,char const *)" (?mysql_query@@$$J18YGHPAUst_mysql@@PBD@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>main.obj : error LNK2019: unresolved external symbol "extern "C" struct st_mysql * __stdcall mysql_real_connect(struct st_mysql *,char const *,char const *,char const *,char const *,unsigned int,char const *,unsigned int)" (?mysql_real_connect@@$$J232YGPAUst_mysql@@PAU1@PBD111I1I@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>main.obj : error LNK2019: unresolved external symbol "extern "C" struct st_mysql * __stdcall mysql_init(struct st_mysql *)" (?mysql_init@@$$J14YGPAUst_mysql@@PAU1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

先感谢您

4

1 回答 1

0

您没有与 MySQL 库链接。

仅仅包含头文件是不够的,项目现在必须在哪里找到 MySQL 可执行代码。您可以通过指定要引入哪些库来告诉它。

在线文档中有一个部分详细说明了您需要做什么,这基本上是将libmysql(假设动态链接,请参阅该链接以获取您想要的静态案例的链接)库到项目中。

于 2012-06-19T03:32:25.527 回答