trying to connect to mysql - gives me linker errors


#include <mysql.h>

and


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//try to make connection to database
	 
		
		MYSQL *connection, mysql;
		MYSQL_RES *result;
		MYSQL_ROW row;
		int query_state;

		mysql_init(&mysql);

		connection = mysql_real_connect(&mysql,"http://1.1.1.1","user","password","database name",0,0,0);
		if (connection != NULL) 
		{
		
		cout << "database connected \n";

		
		}


this code gives me

1>main.obj : error LNK2028: unresolved token (0A000294) "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 (0A0002D4) "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 long)" (?mysql_real_connect@@$$J232YGPAUst_mysql@@PAU1@PBD111I1K@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 long)" (?mysql_real_connect@@$$J232YGPAUst_mysql@@PAU1@PBD111I1K@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)


Ive added this in Visual C++

C++->General->Additional Include Directories

"C:\Program Files\MySQL\MySQL Server 5.1\include"

Linker->General->Additional Library Directories

"C:\Program Files\MySQL\MySQL Server 5.1\lib\opt"

Linker->Input->Additional Dependencies

user32.lib libmysql.lib

Topic archived. No new replies allowed.