Uploaded image for project: 'MariaDB Connector/C++'
  1. MariaDB Connector/C++
  2. CONCPP-110

Compile connector c++ with Visual Studio 2022

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.0.2
    • 1.1.2, 1.0.3
    • General
    • None
    • Windows Server 2016 standard, Visual Studio 2022, conan package manager,
      connector-c 3.3.2, connector-cpp 1.0.2

    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.

      Attachments

        1. conanfile-connector-c.py
          2 kB
        2. conanfile-connector-cpp.py
          2 kB
        3. error.png
          error.png
          76 kB
        4. error2.png
          error2.png
          11 kB
        5. vs17
          0.3 kB

        Activity

          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.

          Lawrin Lawrin Novitsky added a comment - 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.
          sjobeaxe Axel Sjöberg added a comment -

          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.

          sjobeaxe Axel Sjöberg added a comment - 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.

          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?

          Lawrin Lawrin Novitsky added a comment - 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?
          sjobeaxe Axel Sjöberg added a comment -

          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?

          sjobeaxe Axel Sjöberg added a comment - 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?
          Lawrin Lawrin Novitsky added a comment - - edited

          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

          Lawrin Lawrin Novitsky added a comment - - edited 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

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

          Lawrin Lawrin Novitsky added a comment - Could you please try with the same branch once again? Please mind, that I have overwrote previous commit there
          sjobeaxe Axel Sjöberg added a comment -

          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"]

          sjobeaxe Axel Sjöberg added a comment - 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"]

          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

          Lawrin Lawrin Novitsky added a comment - 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

          People

            Lawrin Lawrin Novitsky
            sjobeaxe Axel Sjöberg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.