MySQL Forums
Forum List  »  Connector/C++

Please help. cant get connector to work, unresolved external symbol error
Posted by: Bernie Sensation
Date: May 27, 2024 11:09AM

So, I'm at the end of my tether. I'm one week in now of trying to solve this and I think I'm going insane. Caveat: I am a bit of a noob, so could possibly be doing something stupid.
I plan to make a program to capture data on my serial port and send to my db. I thought before I do so, I would just try out a simple program using the C++ connector, this was it:

#include <mysqlx/xdevapi.h>
#include <iostream>

using namespace ::mysqlx;
using std::cout;

int main() {
cout << "Hello MySQL X DevAPI!" << std::endl;
return 0;

I first started out using codelite and minGW. No joy, so I switched to vs code, again, no joy. Eventually I stumbled on to a youtube video where some kind fella had posted a walkthrough. So now, I'm just trying to get his code working, using VS community 2022. I followed his method, verbatim. This is his code. Yes i know I was using mysqlx before, and I was using the correct library for that. But I'm thinking if I can just get something working, it will probably lead me to why my previous attempts failed. Here is the new code:

#include <stdlib.h>
#include <iostream>
#include "stdafx.h"

#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/prepared_statement.h>
using namespace std;

//for demonstration only. never save your password in the code!
const string server = "tcp://";
const string username = "username@servername";
const string password = "yourpassword";

int main()
sql::Driver* driver;
sql::Connection* con;
sql::Statement* stmt;
sql::PreparedStatement* pstmt;

driver = get_driver_instance();
con = driver->connect(server, username, password);
catch (sql::SQLException e)
cout << "Could not connect to server. Error message: " << e.what() << endl;

//please create database "quickstartdb" ahead of time

stmt = con->createStatement();
stmt->execute("DROP TABLE IF EXISTS inventory");
cout << "Finished dropping table (if existed)" << endl;
stmt->execute("CREATE TABLE inventory (id serial PRIMARY KEY, name VARCHAR(50), quantity INTEGER);");
cout << "Finished creating table" << endl;
delete stmt;

pstmt = con->prepareStatement("INSERT INTO inventory(name, quantity) VALUES(?,?)");
pstmt->setString(1, "banana");
pstmt->setInt(2, 150);
cout << "One row inserted." << endl;

pstmt->setString(1, "orange");
pstmt->setInt(2, 154);
cout << "One row inserted." << endl;

pstmt->setString(1, "apple");
pstmt->setInt(2, 100);
cout << "One row inserted." << endl;

delete pstmt;
delete con;
return 0;

Include path is set to the JDBC folder, and the linker to the vs14 folder, mysqlcppconn-static.lib

Here is the YT tutorial I followed:

And here is my error when I try and build the solution:

Severity Code Description Project File Line Suppression State Details
Error LNK2001 unresolved external symbol "__declspec(dllimport) void __cdecl check(class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &)" (__imp_?check@@YAXAEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z) mysqlProject1 C:\Users\me\Desktop\vs_workspace\mysqlProject1\mysqlProject1\main.obj 1

I would be most grateful if somebody could point me in the right direction of where I am going wrong... I'm literally worn out by it all... If I followed the walkthrough, then why do I get such errors...


Options: ReplyQuote

Written By
Please help. cant get connector to work, unresolved external symbol error
May 27, 2024 11:09AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.