错误LNK2028:未解析的令牌错误

时间:2012-06-19 03:29:08

标签: mysql linker-errors

您好我在尝试编译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)

提前谢谢

1 个答案:

答案 0 :(得分:0)

您没有链接MySQL库。

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

有一个section in the online docs详细说明了你需要做什么,基本上是添加libmysql(假设动态链接,请参阅静态情况的链接,而不是你希望的那个)图书馆到项目。