views:

17

answers:

1

Hello everyone,

I am trying to connect to MySQL using C++. The IDE that I am using is Visual C++ 2010. I followed the steps on the MySQL dev page (http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html). I followed the steps exactly as given although i used a different OS(Windows). I get many linker errors in the process, which I am finding difficult to debug. Could somebody direct me towards a better or a simpler approach to acces MySQL using C++.

P.S. I have downloaded mysqlconnector for C++.

A: 

You could try mysql++, but you'll encounter the same linker errors I bet.

Have you set the include path (C:...\MySQL Server 5.1\include) and the library path (C:...\MySQL Server 5.1\lib\debug) ? In VC2010 to set global settings you have to :

VS2010 introduces the user settings file (Microsoft.cpp..users.props) to control global settings including Global search path. These files are located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory.

The issue you are seeing is a bug in the UI. To make it possible to change the ordering of these read-only directories, here is the workaround that you can apply:

  1. open up the property manager,
  2. right click on the .user.props file to bring up the property page
  3. open up VC++ Directories -> Include Directories, add new paths after $(IncludePath)
  4. Click on the "Edit" dropdown on VC++ Directories -> Include Directories property, the user directories as well as the inherited values will show up in the upper pane
  5. you can move the directory orders as you wish and save.

http://connect.microsoft.com/VisualStudio/feedback/details/550946/vs-2010-how-to-change-vc-directories-inherited-values-read-only

anno
MySQL++ has only one known problem with Visual C++ 2010, that being that you can't currently build it as a 64-bit library, so it can't be linked to a 64-bit program. (That used to work with VC++ 2005 and 2008, and we don't yet know why 2010 breaks it.) 32-bit libraries are the default on Windows, so as long as you follow the instructions and don't change any build settings, you should be fine.
Warren Young
Warren, in building MySQL++ with VC2010 have you encountered the warning MSB8012 (http://connect.microsoft.com/VisualStudio/feedback/details/523864/how-to-fix-msb8012-lib-outputfile).
anno
I set the include path and all the required configurations fo the linker in the project settings correctly. But the linker errors persist. Tried using Turbo C++ but came to know that mysql connector doesnt work with that. Will try mysql++ for now...
mithun1538