MySQL Forums
Forum List  »  Connector/C++

Using MySql and C++
Posted by: harry boy
Date: September 25, 2009 01:15PM

Hi,I want to use MySql with my C++ program, I have included #include <mysql.h> but I got an error saying it culd not be found so I downloaded the VS2005 connector (mysql-connector-c++-noinstall-1.0.5-win32-vs2005.zip) but found that it had no mysql.h file in it at all.

I then downloaded \MySQL Server 5.0 and installed it. I did the following steps:

1. On my project settings n the C++ General Tab I set the "Additional Include Directories" to "C:\Program Files\MySQL\MySQL Server 5.0\include". This has not gotten rid of the "Cannot open include file: 'mysql.h': No such file or directory " error.

2. Now When I include some MySql code such as:
mysql_init(&mysql);

connection = mysql_real_connect(&mysql,"localhost","root","","test1",0,0,0);
if (connection == NULL)
{
cout << mysql_error(&mysql) << endl;
return 1;
}

i get the following errors:

Error 1 error LNK2019: unresolved external symbol _mysql_error@4 referenced in function "int __stdcall StartServer(void)" (?StartServer@@YGHXZ) winSeverForMultipleClient.obj
Error 2 error LNK2019: unresolved external symbol _mysql_real_connect@32 referenced in function "int __stdcall StartServer(void)" (?StartServer@@YGHXZ) winSeverForMultipleClient.obj
Error 3 error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "int __stdcall StartServer(void)" (?StartServer@@YGHXZ) winSeverForMultipleClient.obj


So I then do the following:
3. i add libmysql.lib to the Linker-->Input-->Additional Dependencies section of the Project Settings. The above build errors go away.

4. When I try to run my program I get the following error as a message box:
"This application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem"

5. Then I tried setting the Linker-->General-->Additional Library Directories to "C:\Program Files\MySQL\MySQL Server 5.0\lib\opt" because this is where the file libmysql.lib is actually located but I still get the same error message box.

What am I doing wrong? Am I way off course?

Thanks for any help you can give me onthis, its starting to ruin my weekend :(

Harry

Options: ReplyQuote


Subject
Views
Written By
Posted
Using MySql and C++
6690
September 25, 2009 01:15PM
2578
October 14, 2009 10:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.