I am trying to make a C++ program on Windows that uses MySQL c++ connector and another library that cannot be compiled with MSVC. That's why I need to use MinGW.
I followed the guide on https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-source.html
I used the option -G "MinGW Makefiles" to build the library with MinGW, then installed it. However, when trying to compile a main that only includes xdevapi.h:
#include <mysqlx/xdevapi.h>
int main()
{
return 0;
}
with:
g++ main.cpp -std=c++11 -I'C:\Users\UINKTVA\MySQL\MySQL Connector C++ 8.0.32\include' -L'C:\Users\UINKTVA\MySQL\MySQL Connector C++ 8.0.32\lib64' -lmysqlcppconn8
I get a compilation error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\UINKTVA\AppData\Local\Temp\cch8jmaO.o:main.cpp:(.text$_ZN6mysqlx4abi22r06string6traitsIcE6to_strB5cxx11ERKS2_[_ZN6mysqlx4abi22r06string6traitsIcE6to_strB5cxx11ERKS2_]+0x1c): undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\UINKTVA\AppData\Local\Temp\cch8jmaO.o:main.cpp:(.rdata$.refptr._ZTVN6mysqlx4abi22r05DbDocE[.refptr._ZTVN6mysqlx4abi22r05DbDocE]+0x0): undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
collect2.exe: error: ld returned 1 exit status
I do not understand what is the problem, is the source code of cppconnector faulty? Please help if you can. I've been stuck on this for a while. I'm not new to compiling, linking etc. I can make the library work on linux, Mac, and on Visual Studio. But as I said unfortunately I need to make it work on Windows using MinGW.