[CONCPP-59] Unable to use Connector/C++ on Windows Created: 2021-01-26  Updated: 2021-02-04  Resolved: 2021-02-04

Status: Closed
Project: MariaDB Connector/C++
Component/s: General
Affects Version/s: 0.9.4
Fix Version/s: 1.0.0

Type: Bug Priority: Blocker
Reporter: Rob Hedgpeth (Inactive) Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 64-bit



 Description   

Using the documentation instructions here -> https://mariadb.com/docs/appdev/connector-cpp/ I attempted to install, configure, and compile a sample C++ application (on Windows 64-bit) that uses Connector/C.

After installing the latest Windows 64-bit version from https://mariadb.com/downloads/#connectors, I attempted to compile a sample application using:

g++ -o example example.cpp -std=c++11 -lmariadbcp

To which I received the following:

PS C:\Users\Rob\Development\dev-example-todo\console\cpp> g++ -o test test.cpp -lmariadbcpp
test.cpp:2:9: fatal error: mariadbcpp/ConnCpp.h: No such file or directory
#include<mariadbcpp/ConnCpp.h>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

After receiving advice from Larwin I removed the "mariadbcpp" library directory from the include, and instead executed a command to include the header files directly:

g++ -o test test.cpp -std=c++11 -I"C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include"

To which I received an error:

PS C:\Users\Rob\Development\dev-example-todo\console\cpp> g++ -o test test.cpp -std=c+11 -I"C:\Program Files\MariaDB\MariaDB C+ Connector 64-bit\include"
In file included from C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include/ConnCpp.h:24,
from test.cpp:2:
C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include/Driver.h:24:10: fatal error: buildconf.h: No such file or directory
#include "buildconf.h"
compilation terminated.

I then git cloned the source from https://github.com/mariadb-corporation/mariadb-connector-cpp and built an MSI. Then I manually copied over the buildconf.h file into the installed MariaDB Connector/C folder (in Program Files). After some back and forth testing I discovered I needed to add a few more headers.

The missing header files:

  • buildconf.h
  • CArray.h
  • DriverManager.h

However, after copying over the missing headers I still encountered the following error, and am unsure how to resolve:

C:\Users\Rob\Development\dev-example-todo\console\cpp>g++ -o test test.cpp -std=c+11 -I"C:\Program Files\MariaDB\MariaDB C+ Connector 64-bit\include"
In file included from C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include/ConnCpp.h:39,
from test.cpp:2:
C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include/Exception.h:47:30: error: function 'sql::SQLString sql::SQLException::getSQLState()' definition is marked dllimport
MARIADB_EXPORTED SQLString getSQLState()

{ return SqlState.c_str(); }
^~~~~~~~~~~
C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include/Exception.h:48:32: error: function 'const char* sql::SQLException::getSQLStateCStr()' definition is marked dllimport
MARIADB_EXPORTED const char* getSQLStateCStr() { return SqlState.c_str(); }

^~~~~~~~~~~~~~~
C:\Program Files\MariaDB\MariaDB C++ Connector 64-bit\include/Exception.h:52:32: error: function 'const char* sql::SQLException::what() const' definition is marked dllimport
MARIADB_EXPORTED char const* what() const noexcept override

{ return std::runtime_error::what(); }

Please reach out to me if you need any more details.



 Comments   
Comment by Lawrin Novitsky [ 2021-02-04 ]

Commit ffb3ba5

Comment by Rob Hedgpeth (Inactive) [ 2021-02-04 ]

You rock!

Generated at Thu Feb 08 03:08:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.