• 0

Basic C++ project with MySQL Connector


Question

Recently I tried creating same code in JAVA as in C# to brush up on JAVA - a similar helper library for easy querying of database and object mapping In the end I realized that Java is a terrible language (forced exception checking, terrible reflection, and lack of support for generics). Anyway, now I want to do the same thing (or at least attempt to) in C++ to learn C++

First thing first, I am trying to get MySQL connector to work with C++

  • I installed MySQL connector to C:\Program Files\MySQL\MySQL Connector C++ 1.1.6
  • I then created a Win32 Console Application project in VS2015
  • In "Additional Include Directories" I have, ("C/C++" - "General")
  Quote

C:\Program Files\MySQL\MySQL Connector C++ 1.1.6\include\cppconn
C:\Program Files\MySQL\MySQL Connector C++ 1.1.6\include
%(AdditionalIncludeDirectories)

  •  In "Additional Library Directories". Have, ("Linker" - "General")
  Quote

C:\Program Files\MySQL\MySQL Connector C++ 1.1.6\lib\opt
%(AdditionalLibraryDirectories)

  • In "Additional Dependencies" I have,
  Quote

mysqlcppconn-static.lib
libmysql.lib
%(AdditionalDependencies) 

Then I try, to add,

#include "mysql_connection.h"

This file exists in the "include" directory, but I get error "cannot open source file"

 

 

 

 

So then I tried to build the thing from source (C++ libraries incompatible with each other unless built using the same compiler???), first attempt was like,

  Quote

SET PATH=%PATH%;C:\Program Files (x86)\CMake\bin
cd "C:/Users/{0}/Documents/C++/mysql-connector-c++-1.1.6"
cmake -G "Visual Studio 14 2015 Win64" -DBOOST_ROOT:STRING="C:\Users\{0}\Documents\C++\boost_1_59_0" -DMYSQL_CLIENT_STATIC_LINKING=1 -DMYSQL_INCLUDE_DIR="C:\Users\{0}\Documents\C++\MySQL Connector C++ 1.1.6\include"

Which produced a "could not find a "mysql.h"" so... next up I followed a different set of directions based on post by Atul Patil in http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows-visual-studio.html which stated that I needed to build the MySQL server first to build the connector.

So I extracted the source for "mysql-5.6.26", navigated via CMD to, mysql-5.6.26/BUILD and ran "cmake .. -G "Visual Studio 14 2015 Win64"" which worked. I opened the generated solution in Visual Studio and mysqlclient which failed with,

Error LNK1181 cannot open input file 'C:/Users/{0}/Documents/C++/mysql-5.6.26/BUILD/libmysql/Debug/clientlib.lib' mysqlclient C:\Users\{0}\Documents\C++\mysql-5.6.26\BUILD\libmysql\LINK 1

Thoughts? TBH getting things to compile and run was my primary reason to avoid C++ in the past - followed by header files

 

 

EDIT,

Pile of ###### doesn't support VS 2015 yet, what a ######## disgrace,

http://forums.mysql.com/read.php?117,634127,634127#msg-634127 

 

Edited by _Alexander

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Posts

    • Oh no... here we go again. Tha same sh*t that happaned to Mail & Calendar...
    • I too have worked with pro gear for decades and so I found the interface to be unintuitive from both the pro and casual side (a rare "accomplishment" by what are obviously otherwise skilled coders, hehe). I eventually got it to work, thanks for offering, but I found other compatibility issues with my own use case, so I just dropped it entirely. Right now, I just use an analog line out/line in approach which works as expected across all usage scenarios. With both machines on the same power block/outlet, I'm not getting any analog hum or hiss. My next step will be to try the updated Multiplicity 4 when a bug, addressing this very issue unfortunately, is resolved. Knowing Stardock, that could be tomorrow or five years from now, so I check back every few months to see it it's fixed and I want to upgrade. Again, thanks for offering to help.
    • We recognize that performance can use some improvements, and we continue to work on improving it. However, it's worth noting that massive performance improvements don't happen overnight, they take a lot of work and effort, and in most cases, the improvements are more noticeable when you compare across several updates. That said, Files is open-source and everyone is invited to help with these efforts 🙂
    • A lot of effort has gone into improving stability and Files Preview now has a 99% crash free rate. These improvements will make their way to Files Stable when v4 is released later this year. If you're still experiencing issues, please report them on GitHub or Discord so we can track them properly.
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      Michael Scrip
      203
    3. 3
      ATLien_0
      197
    4. 4
      Xenon
      137
    5. 5
      +FloatingFatMan
      115
  • Tell a friend

    Love Neowin? Tell a friend!