Bug #87159 Undefined Reference To get_driver_instance
Submitted: 21 Jul 2017 13:18 Modified: 8 Feb 2018 9:49
Reporter: Mauro Oliveira Maurão Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:-8.0.5 OS:Windows (Visual Studio )
Assigned to: CPU Architecture:Any

[21 Jul 2017 13:18] Mauro Oliveira Maurão
Description:
Dear Sirs, Good Morning!

   Since a month, I'm looking for solutions in many foruns but I did not find.
We've got allways the same message: [Undefined Reference To get_driver_instance].

  All includes paths are defined and well inserted. 

DownLoaded files:
 mysql-connector-c++-8.0.5-dmr-windows-x86-64bit
 Bosst librarys
 Visual GDB

We did not find the source of this funtion [get_driver_instance()] in any include file.

We need a lot your help please.

How to repeat:
This bug happens BY compile the folloing so simple exemple in Visual Studio:
int main(void)
{/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <memory>
#include <string>
#include <stdexcept>
#include <string>
/* MySQL Connector/C++ specific headers */
//#include "mysql_connection.h"
#include "mysql_driver.h" 
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/connection.h>
#include <cppconn/metadata.h>
#include <cppconn/resultset_metadata.h>
#include <cppconn/warning.h>
using namespace std;
using namespace sql;

#pragma once 
	cout << endl;
	cout << "Let's have MySQL count from 10 to 1..." << endl;
	try {
		sql::Driver *driver;
		sql::Connection *con;
		sql::Statement *stmt;
		sql::ResultSet *res;
		sql::PreparedStatement *pstmt;
		/* Create a connection */	

		driver = get_driver_instance();  //? <=== PROBLEM HEAR
										
		con = driver->connect("tcp://192.168.0.100:3306", "root", "root");
		/* Connect to the MySQL test database */
		con->setSchema("test");

		stmt = con->createStatement();
		stmt->execute("DROP TABLE IF EXISTS test");
		stmt->execute("CREATE TABLE test(id INT)");
		delete stmt;
		  /* '?' is the supported placeholder syntax */
		pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
		for (int i = 1; i <= 10; i++) {
			pstmt->setInt(1, i);
			pstmt->executeUpdate();
		}
		delete pstmt;

		  /* Select in ascending order */
		pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
		res = pstmt->executeQuery();

		  /* Fetch in reverse = descending order! */
		res->afterLast();
		while (res->previous())
			cout << "\t... MySQL counts: " << res->getInt("id") << endl;
		delete res;

		delete pstmt;
		delete con;

	}
	catch (sql::SQLException &e) {
		cout << "# ERR: SQLException in " << __FILE__;
		cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
		cout << "# ERR: " << e.what();
		cout << " (MySQL error code: " << e.getErrorCode();
		cout << ", SQLState: " << e.getSQLState() <<  " )" << endl;
	}
	cout << endl;
	return EXIT_SUCCESS;
}
[8 Feb 2018 9:49] Chiranjeevi Battula
Hello Mauro,

Thank you for the bug report.
I could not repeat the issue at our end using Visual Studio 2017 and Connector / C++ 8.0.6 version.
please map libraries properly https://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows-visual-studio.html

Thanks,
Chiranjeevi.