Hello I am getting these LNK errors when I try to compile my MySQL connection code
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)
thank you in advance
You’re not linking with the MySQL libraries.
It’s not enough to just include the header files, the project has to now where to find the MySQL executable code. You tell it this by specifying which libraries to bring in.
There’s a section in the online docs which details what you need to do, which is basically add the
libmysql(assuming dynamic linking, see that link for the static case on the off-chance you want that instead) library to the project.