Re: How to build mysqlclient.lib 5.7 without MSVCR120 dependency
Posted by: Adrián G.
Date: August 20, 2022 05:43AM

So far I've advanced a lot towards my goals, although not completely. If useful to anyone, here are the steps I've followed and which contain few changes to past failing compilation steps.

Updated MySQL 5.7 requires OpenSSL to compile, so, I installed ActiveState's Perl -which is required to build it-, after my own complications due to a newer CLI usage requirement on them ("state tool"), which I may save from explaining.

Then I ran the following in VS2013 x86 Native Tools Command Prompt:

perl Configure VC-WIN32 /MT no-asm no-comp no-shared no-ssl2 no-ssl3 no-threads
nmake
nmake install

Static libcrypto.lib and libssl.lib then generate on "C:\Program Files (x86)\OpenSSL\lib".

Then, I run, in x86 Native Tools Command Prompt for VS 2022, having CMake for Windows C++ installed through VS Installer, this MySQL solution generation command:

cmake -Bbuild -G "Visual Studio 12 2013" -Tv120_xp -DBUILD_CONFIG=mysql_release -DLINK_STATIC_RUNTIME_LIBRARIES=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../my_boost -DWITH_SSL="C:\Program Files (x86)\OpenSSL" -DWITHOUT_SERVER=1

Notice the -DLINK_STATIC_RUNTIME_LIBRARIES=1 flag, which is an undocumented way to force the /MT - /MTd runtime library options automatically and I found from Windows.cmake file. Afterwards, I switch to MinSizeRel within solution's VS build modes and manage to compile it successfully. I link generated mysqlclient.lib in my custom program that uses MySQL client and it compiles successfully under Release mode (note I need to link against crypt32.lib since the SSL requirement). However, if I use Debug mode, I get (only) the following errors:

2>libcpmtd0.lib(xthrow.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in mysqlclient.lib(net_serv.obj)
2>libcpmtd0.lib(syserror.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in mysqlclient.lib(net_serv.obj)

Compiling the MySQL client under Debug mode should fix it, but I'd like to avoid having two separate client libraries (for each mode), just like I could in the old version 1.6.9. Would there be some trick to skip the errors it otherwise?

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to build mysqlclient.lib 5.7 without MSVCR120 dependency
59
August 20, 2022 05:43AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.