简体   繁体   中英

Using MySQL in C++ in Visual Studio 2019

I'm trying to use MySQL in my C++ program developed in Visual Studio 2019.

While trying include MySQL libraries with #include <cppconn/driver.h> (or anything else that is being included in the sample code in MySQL Documentation) it shows an error: "cannot open source file cppconn/driver.h".

So far I've installed and configured the following programs:

  • MySQL Shell 8.0.22
  • MySQL Connector C++ 8.0.22
  • MySQL Installer for Windows - Community (used to install everything else)
  • MySQL for Visual Studio 1.2.9
  • MySQL Server 8.0.22
  • MySQL Router 8.0.22
  • MySQL Workbench 8.0.22 CE

I've already started a local MySQL server and the VS 2019 itself (not the programs written in it) can connect to it. Compiling C++ programs without MySQL also works fine.

I suspect that I need to show VS 2019 where to find these libraries, but I don't know how to do that. Can you help me with that?

So I re-run the installation of MySQL Connector C++ and chose the custom setup option. The Dll libraries were included, but Development Components were not. I changed that and magically a whole set of.h files that I was looking for appeared under the new "MySQL_Connector_C++_8.0/include" directory. I've promptly added those under Include Directories of my project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM