1

I am writing a C++ program in Visual Studio 2019 that connects to a local MySql Database using C++ MySql connector. I am using the example code provided on the MySQL website.

sql::Driver* driver;
sql::Connection* con;
sql::Statement* stmt;
sql::ResultSet* res;


driver = get_driver_instance();
con = driver->connect("localhost", "root", "password");

con->setAutoCommit(0);


con->setSchema("testdatabase");

stmt = con->createStatement();
res = stmt->executeQuery("SELECT TestCode FROM testdatabase.test;");
delete res;
delete stmt;
delete con;

However I keep getting the same errors, no matter what I try:

The errors

I'm pretty sure it's related to this line of code, as removing it gets rid of the error

driver = get_driver_instance();

Does anyone know what causes this? I have been searching for an answer for hours and can't seem to find a fix

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    Looks like you are missing linking to an import library. – drescherjm Jun 18 '21 at 01:45
  • Looks like the `check` function is declared in your code, have you forgotten to define it? – prehistoricpenguin Jun 18 '21 at 01:52
  • You're missing the required `lib` file. How did you install the library? Did you use a package manager? – WBuck Jun 18 '21 at 02:33
  • @WBuck I read an answer to a question somewhere on stack overflow that said I only needed to use #include then the file path for four of the files included in the Connector file. How exactly do I install a library? – balancedflame79 Jun 18 '21 at 10:26
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Botje Jun 18 '21 at 11:25
  • @botje It more or less confirms what I already know about the error but it doesn’t completely answer my question. I think I have found a way to fix it. I just have to see if it works. – balancedflame79 Jun 18 '21 at 12:06

0 Answers0