Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Can't build DLL on windows #55

Closed
tan-tan-kanarek opened this issue Aug 15, 2019 · 2 comments
Closed

Can't build DLL on windows #55

tan-tan-kanarek opened this issue Aug 15, 2019 · 2 comments

Comments

@tan-tan-kanarek
Copy link

I try to use sqlpp11 on my development Windows machine, where I use Visual Studio to create C# .net core that use C++ DLL that use sqlpp11.
I managed to create Visual Studio project using:

cmake -G "Visual Studio 16 2019"

After few tweaks I managed to configure VS to produce a DLL for tests and windows dev, however I would like to make it easily (CLI) reproducible by other developers.
The command I was trying to use are:

cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=True -DCMAKE_INSTALL_PREFIX=C:\DataLayer\sqlpp11-connector-mysql\build\x64_Debug\lib -DDATE_INCLUDE_DIR=c:\DataLayer\date\include -DSQLPP11_INCLUDE_DIR=c:\DataLayer\sqlpp11\include "-DMYSQL_LIBRARY=C:\dev\mysql-connector-debug-x64\lib\libmysql.lib" "-DMYSQL_INCLUDE_DIR=C:\dev\mysql\include" ....

nmake /f Makefile MACHINE=x64 VC=19 install

The unfortunate outcome of this build is as followed:

connection_handle.cpp.obj : error LNK2019: unresolved external symbol mysql_init referenced in function "public: __cdecl sqlpp::mysql::detail::connection_handle_t::connection_handle_t(class std::shared_ptr<struct sqlpp::mysql::connection_config> const &)" (??0connection_handle_t@detail@mysql@sqlpp@@QEAA@AEBV?$shared_ptr@Uconnection_config@mysql@sqlpp@@@std@@@Z)
connection_handle.cpp.obj : error LNK2019: unresolved external symbol mysql_real_connect referenced in function "public: __cdecl sqlpp::mysql::detail::connection_handle_t::connection_handle_t(class std::shared_ptr<struct sqlpp::mysql::connection_config> const &)" (??0connection_handle_t@detail@mysql@sqlpp@@QEAA@AEBV?$shared_ptr@Uconnection_config@mysql@sqlpp@@@std@@@Z)
connection_handle.cpp.obj : error LNK2019: unresolved external symbol mysql_ping referenced in function "public: bool __cdecl sqlpp::mysql::detail::connection_handle_t::is_valid(void)" (?is_valid@connection_handle_t@detail@mysql@sqlpp@@QEAA_NXZ)
connection_handle.cpp.obj : error LNK2019: unresolved external symbol mysql_options referenced in function "public: __cdecl sqlpp::mysql::detail::connection_handle_t::connection_handle_t(class std::shared_ptr<struct sqlpp::mysql::connection_config> const &)" (??0connection_handle_t@detail@mysql@sqlpp@@QEAA@AEBV?$shared_ptr@Uconnection_config@mysql@sqlpp@@@std@@@Z)
connection_handle.cpp.obj : error LNK2019: unresolved external symbol mysql_close referenced in function "void __cdecl sqlpp::mysql::detail::handle_cleanup(struct MYSQL *)" (?handle_cleanup@detail@mysql@sqlpp@@YAXPEAUMYSQL@@@Z)
sqlpp-mysql.dll : fatal error LNK1120: 34 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\nmake.exe"' : return code '0x2'
Stop.

It's worth mentioning that when BUILD_SHARED_LIBS=False everything built smoothly.

BTW, very cool project.

@rbock
Copy link
Owner

rbock commented Aug 15, 2019

Hi,
Thanks for the report!

Seems like an issue with one of the CMakeLists.txt. However, I have no good way of testing and fixing this, as I do not have a Windows machine available. Can you try to figure it out and create a pull request?

Thanks,

Roland

@Toxe
Copy link
Contributor

Toxe commented Mar 11, 2020

Hello @tan-tan-kanarek, in case this is still an issue: I made a small test project that builds and works on Windows (and Linux, macOS), maybe that can help you out.

It is sqlpp11_mysql.cpp from: https://github.com/Toxe/cpp-sql

Configuring and building this on Windows was actually fairly straightforward, compared to macOS and Linux. Oh and I am using Vcpkg.

@rbock rbock closed this as completed Dec 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants