[CONCPP-110] Compile connector c++ with Visual Studio 2022 Created: 2022-11-07  Updated: 2022-11-16  Resolved: 2022-11-16

Status: Closed
Project: MariaDB Connector/C++
Component/s: General
Affects Version/s: 1.0.2
Fix Version/s: 1.1.2, 1.0.3

Type: Bug Priority: Major
Reporter: Axel Sjöberg Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows Server 2016 standard, Visual Studio 2022, conan package manager,
connector-c 3.3.2, connector-cpp 1.0.2


Attachments: Text File conanfile-connector-c.py     Text File conanfile-connector-cpp.py     PNG File error.png     PNG File error2.png     HTML File vs17    

 Description   

I'm in the progress of transition from Visual Studio 2017 to 2022. When trying to compile the c++ connector, I get the error shown in the attachments. I have created Conan package manager recipes for the connector and I provided them too, including my conan profile file. Compiling with or without Conan, I still end up having the compilation abort with the same dynamic_cast error. I have also tried to build with MSBuild and Ninja. I have exhausted my ideas about how to fix this.



 Comments   
Comment by Lawrin Novitsky [ 2022-11-15 ]

Thank you for your report.
It is strange, though, as I myself use vs2022 primarily since quite some time. Just tried to recompile that unit - no errors. Atm I am also out of ideas, except that connector's exceptions system is a bit ugly, but I knew that before

Could you give me complete instruction with exact commands how to repeat it? Preferably w/out Conan. I gather you were taking release source package, as the first step.

Comment by Axel Sjöberg [ 2022-11-15 ]

I tried it again, this time by getting the source code from github as opposed to downloading it from the connectors downloads page. Unfortunately it failed again.

*C:\mariadbconnector>git clone https://github.com/mariadb-corporation/mariadb-connector-cpp.git
Cloning into 'mariadb-connector-cpp'...
C:\mariadbconnector\mariadb-connector-cpp>git submodule init
C:\mariadbconnector\mariadb-connector-cpp>git submodule update
Cloning into 'C:/mariadbconnector/mariadb-connector-cpp/libmariadb'...
Submodule path 'libmariadb': checked out '1bd8c8bf39c259a1b1713974684e24d168a09d13'
C:\mariadbconnector\mariadb-connector-cpp\build>cmake ..
C:\mariadbconnector\mariadb-connector-cpp\build>cmake --build . --target=install

Compiling results in these errors:

zutil.c
Generating Code...
mariadb_obj.vcxproj -> C:\mariadbconnector\mariadb-connector-cpp\build\libmariadb\libmariadb\mariadb_obj.dir\Debug\mariadb_obj.lib
Building Custom Rule C:/mariadbconnector/mariadb-connector-cpp/libmariadb/libmariadb/CMakeLists.txt
Creating library C:/mariadbconnector/mariadb-connector-cpp/build/libmariadb/libmariadb/Debug/libmariadb.lib and object C:/mariadbconnector/mariadb-connector-cpp/build/libmariadb/libmariadb/Debug/libmariadb.exp
libmariadb.vcxproj -> C:\mariadbconnector\mariadb-connector-cpp\build\libmariadb\libmariadb\Debug\libmariadb.dll
Building Custom Rule C:/mariadbconnector/mariadb-connector-cpp/libmariadb/libmariadb/CMakeLists.txt
mariadbclient.vcxproj -> C:\mariadbconnector\mariadb-connector-cpp\build\libmariadb\libmariadb\Debug\mariadbclient.lib
The system cannot find the path specified.
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'C:\mariadbconnector\mariadb-connector-cpp\build\CMakeFiles\de43d36b0afa0fd33
8a5da31509ccaab\WIXOBJ.rule;C:\mariadbconnector\mariadb-connector-cpp\libmariadb\win\packaging\CMakeLists.txt' exited with code 3. [C:\mariadbconnector\mariadb-connector-cpp\build\libmariadb\win\packaging\WIXOBJ.vcxproj]
Building Custom Rule C:/mariadbconnector/mariadb-connector-cpp/CMakeLists.txt
Building Custom Rule C:/mariadbconnector/mariadb-connector-cpp/CMakeLists.txt
MariaDbDriver.cpp
QueryProtocol.cpp
C:\mariadbconnector\mariadb-connector-cpp\src\MariaDBException.h(51,32): error C2683: 'dynamic_cast': 'sql::MariaDBExceptionThrower' is not a polymorphic type [C:\mariadbconnector\mariadb-connector-cpp\build\mariadbcpp.vcxproj]
SimpleParameterMetaData.cpp
C:\mariadbconnector\mariadb-connector-cpp\src\MariaDBException.h(51,32): error C2683: 'dynamic_cast': 'sql::MariaDBExceptionThrower' is not a polymorphic type [C:\mariadbconnector\mariadb-connector-cpp\build\mariadbcpp.vcxproj]

Earlier I tried compiling the c++ connector by downloading it from the downloads connectors page. Because the libmariadb folder is empty in the downloaded c++ connector source files, I manually then copied the c connector source code from the same downloads page into the libmariadb folder. Essentially a manual git submodule init. The cmake commands to compile I did just like above. I have also tried changing compilation options like WITH_MSI and the like that you can find in src/cmake/options_defaults.cmake.

Comment by Lawrin Novitsky [ 2022-11-15 ]

Thanks. I haven't tried to repeat - at first look there is nothing fancy in your instructions.

But I've made change that may please your compiler, based on the error message I saw on the screenshot. Could you please try to build from the https://github.com/mariadb-corporation/mariadb-connector-cpp/tree/1.0-concpp-110 branch?

Comment by Axel Sjöberg [ 2022-11-15 ]

The SimpleParameterMetaData.cpp compilation error is gone! QueryProtocol.cpp error is still there. The "error MSB8066: Custom build" error disappears if I set WITH_MSI=OFF. Whatever you did to the first .cpp file, can you do to the second?

Comment by Lawrin Novitsky [ 2022-11-15 ]

I can't see the same thing in the QueryProtocol.cpp
But also I can't see anything in your error messages and screenshots, that says, that the error is in the QueryProtocol.cpp
Could you provide the text for the error with some context maybe?
Upd: Or maybe I do see it in error message. But still no luck in finding error in the code

Comment by Lawrin Novitsky [ 2022-11-15 ]

Could you please try with the same branch once again? Please mind, that I have overwrote previous commit there

Comment by Axel Sjöberg [ 2022-11-16 ]

It works! Thanks a lot!

Below is my recipe for building this patch. An official mariadb-connector-cpp package recipe to https://github.com/conan-io/conan-center-index would be great! Mariadb-connector-c can already be found there, but its version is quite old.

def source(self):
self.run("git clone https://github.com/mariadb-corporation/mariadb-connector-cpp.git")
self.run("cd mariadb-connector-cpp && git checkout 1.0-concpp-110 && git submodule init && git submodule update")

def build(self):
cmake = CMake(self)
cmake.definitions["WITH_MSI"] = "OFF"
cmake.configure(source_folder="mariadb-connector-cpp")
cmake.build()

def package(self):
self.copy("*.hpp", dst="include/mariadb", src="mariadb-connector-cpp\include")
self.copy("*mariadbcpp.lib", "lib", "", keep_path=False)
self.copy("*mariadbcpp.dll", "bin", "", keep_path=False)

def package_info(self):
self.cpp_info.libs = ["mariadbcpp"]

Comment by Lawrin Novitsky [ 2022-11-16 ]

I am closing the issue then. It's a bit interesting, what is wrong with MSI assembling, but unlikely anybody needs MSI, except us, and for us it works

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