Reputation: 95
I've spent the last 4 days trying to accomplish the following task: - create a MySQL Database - connect to the database in a c++ win32 application so I can use the data and/or edit the data.
So far so good, I'm using the following: - Packard Bell with 64bit Windows 7 Home Edition - Visual C++ Express 2010 - Downloaded and installed mysql 5.5 (choosing the complete installation)
I have no problems using the mysql terminal and creating a simple Database, however establishing a connection to it in my c++ code is a major hurdle. Some tutorials, forums etc. recommend connecting directly and others suggest using ODBC. The first suggestion leads to a ton of issues with Visual Studio not being able to find source files when including header files: mysql_connection.h
cppconn/driver.h
cppconn/exception.h
etc...
could not find the solution for these issues so I turned to ODBC and found the following code:
(see next post, was not allowed to post more than 2 links)
The code actually compiles but can't find anything. See screen below: http://imageshack.dk//viewimage.php?file=/imagesfree/CD525364.jpg
I can't find the solution for the problem. This ODBC Data source "mysql" has been set up manually as shown below: http://imageshack.dk//viewimage.php?file=/imagesfree/WEG25517.jpg
I've read the official mysql documentation for setting up visual studio with the right directories and libraries and since the code compiles that can't be the problem right?
I would really appreciate any help or suggestions :) thanks in advance.
Upvotes: 2
Views: 4988
Reputation: 311
Have you configured your project properties? I am assuming that you've installed MySQL at C:\MySQL
Open visual studio --> Solution Explorer --> Right Click --> Properties --> C/C++ --> General --> Add Include Directories --> Click to edit and write C:\MySQL\include (or where ever you've installed MySQL and locate its include folder).
Now in same properties dialog navigate to Linker --> General --> "Add additional Library Directories" --> (write the path of folder which contains .dll or .lib files e.g. C:\MySQL\Connector ODBC)
In same properties dialog navigate to Linker --> Input --> Additional Dependencies --> (write the name of .lib file you want to use e.g. libmysql.lib or any other library you want to use which is placed in above "Additional Libraray Directories").
Hope it will help you.
Upvotes: 2