问题
I have succeeded compiling POCO libraries with MinGW64 (MSYS2).
To build it, I installed Windows SDK and added to the PATH environment the path to mc.exe, so I executed:
pacman -S mingw-w64-x86_64-cmake
# Get POCO
git clone -b master https://github.com/pocoproject/poco.git
# set Windows SDK to the PATH
export PATH="/c/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64:$PATH"
# Prepare compilation
cd poco
/mingw64/bin/cmake -G "MSYS Makefiles" ..
# Compile
make
The compilation succeeded and libraries were generated.
Then, in the code of my c++ project, I use POCO::Data::ODBC and register it with:
Poco::Data::ODBC::Connector::registerConnector();
The application compiles, but there is a linker error:
undefined reference to `Poco::Data::ODBC::Connector::registerConnector()'
Inspecting the library libPocoDataODBC.dll with dllexp.exe I can confirm there is no entry point defined for Poco::Data::ODBC::Connector::registerConnector()
Any idea of the reason of this lack of entry points in the library? My code accesses other POCO libraries with no problem. IT only affects Poco::Data::ODBC.
Note: I'm linking the librares with parameters
-lPocoDataODBC -lPocoData -lPocoNet -lPocoJSON -lPocoUtil -lPocoFoundation -lPocoNetSSL -lPocoXML
I can see a similar question at this question but with no answer...
回答1:
I've just found the solution. I leave it here just in case someone finds it useful.
There are some warnings compiling files for Data/ODBC: something like
redeclared without dllimport attribute: previous dllimport ignored
for files Data\ODBC\src\Extractor.cpp and Data\ODBC\src\Preparator.cpp.
Regardless these warnings, the files are compiled. But when the library is generated it lacks of entry points, as exposed in my question.
The solution is to add #include "Poco/Foundation.h" at the beginning of Data\ODBC\src\Extractor.cpp and Data\ODBC\src\Preparator.cpp.
I could guess this from this poco issue.
来源:https://stackoverflow.com/questions/58599269/poco-libraries-mingw-msys2-compilation-has-generated-libpocodataodbc-dll-with