neoxyn 0 Newbie Poster

#include <mysql.h>

and

//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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.