Bug #93077 MySql build failed on MSVC on windows
Submitted: 5 Nov 2018 9:44 Modified: 13 Nov 2018 18:50
Reporter: Quella Zhang Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0, 8.0.13 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[5 Nov 2018 9:44] Quella Zhang
Description:
MySql failed with lots of errors when build with msvc on Windows, I use latest source version e4924f3 on MySQL 8.0 branch. I notice that lots of files  lost "<stdexcept>" head file. Could you please help take a look at this?

failure:
D:\MySQL\src\router\src\router\include\mysqlrouter\uri.h(51,30): error C2039: 'runtime_error': is not a member of 'std'
class URIError : public std::runtime_error {
                             ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\include\vector(19): note: see declaration of 'std'
_STD_BEGIN
D:\MySQL\src\router\src\router\include\mysqlrouter\uri.h(51,44): error C2504: 'runtime_error': base class undefined
class URIError : public std::runtime_error {
                                           ^
D:\MySQL\src\router\src\router\include\mysqlrouter\uri.h(55,14): error C2039: 'runtime_error': is not a member of 'std'
      : std::runtime_error(what_arg) {}
             ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\include\vector(19): note: see declaration of 'std'
_STD_BEGIN
D:\MySQL\src\router\src\router\include\mysqlrouter\uri.h(54,7): error C2614: 'mysqlrouter::URIError': illegal member initialization: 'runtime_error' is not a base or member
  explicit URIError(const std::string &what_arg)
      ^
D:\MySQL\src\router\src\router\src\uri.cc(61,12): error C2614: 'mysqlrouter::URIError': illegal member initialization: 'runtime_error' is not a base or member
    : std::runtime_error(std::string("invalid URI: ") + msg + " at position " +
registry.cc
D:\MySQL\src\router\src\harness\src\logging\registry.cc(26,1): warning C4005: 'WIN32_LEAN_AND_MEAN': macro redefinition
#define WIN32_LEAN_AND_MEAN
^
D:\MySQL\src\router\src\harness\src\logging\registry.cc: note: see previous definition of 'WIN32_LEAN_AND_MEAN'

C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\process.h(360,42): error C2556: 'int GetCurrentProcessId(void)': overloaded function differs only by return type from 'DWORD GetCurrentProcessId(void)'
        _ACRTIMP int __cdecl getpid(void);
                                         ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\processthreadsapi.h(126): note: see declaration of 'GetCurrentProcessId'
GetCurrentProcessId(
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\process.h(360,30): error C2371: 'GetCurrentProcessId': redefinition; different basic types
        _ACRTIMP int __cdecl getpid(void);
                             ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\processthreadsapi.h(126): note: see declaration of 'GetCurrentProcessId'
GetCurrentProcessId(
D:\MySQL\src\router\src\harness\src\logging\registry.cc(347,41): warning C4273: 'log_message': inconsistent dll linkage
                            va_list ap) {
                                        ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(343,5): note: see previous definition of 'log_message'
    log_message(LogLevel level, const char *module, const char *fmt,
    ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(384,28): error C2065: 'GetCurrentProcessId': undeclared identifier
        {LogLevel::kError, getpid(), now, g_main_app_log_domain, msg});
                           ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(383,11): error C2664: 'void mysql_harness::logging::Logger::handle(const mysql_harness::logging::Record &)': cannot convert argument 1 from 'initializer list' to 'const mysql_harness::logging::Record &'
    logger.handle(
          ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(384,70): note: Reason: cannot convert from 'initializer list' to 'const mysql_harness::logging::Record'
        {LogLevel::kError, getpid(), now, g_main_app_log_domain, msg});
                                                                     ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(384,70): note: Invalid aggregate initialization
        {LogLevel::kError, getpid(), now, g_main_app_log_domain, msg});
                                                                     ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(396,24): error C2065: 'GetCurrentProcessId': undeclared identifier
  Record record{level, getpid(), now, module, message};
                       ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(396,54): error C2440: 'initializing': cannot convert from 'DWORD (__cdecl *)(void)' to 'DWORD'
  Record record{level, getpid(), now, module, message};
                                                     ^
D:\MySQL\src\router\src\harness\src\logging\registry.cc(396,54): note: There is no context in which this conversion is possible
  Record record{level, getpid(), now, module, message};
                                                     ^

D:\MySQL\src\router\src\http\include\mysqlrouter\http_common.h(246,64): error C2039:  'to_string': is not a member of 'std' [D:\MySQL\build_x64\router\src\http\src\http_common.vcxproj]
D:\MySQL\src\router\src\http\include\mysqlrouter\http_common.h(246,64): error C2039:       throw std::logic_error("no text for HTTP Status " + std::to_string(key)); [D:\MySQL\build_x64\router\src\http\src\http_common.vcxproj]
D:\MySQL\src\router\src\http\include\mysqlrouter\http_common.h(246,64): error C2039:                                                                ^ (compiling source file D:\MySQL\src\router\src\http\src\http_common.cc) [D:\MySQL\build_x64\router\src\http\src\http_common.vcxproj]

How to repeat:
1.git clone https://github.com/mysql/mysql-server.git D:\MySQL\src
2.it's rely on boost 1.67,so extract boost_1_67_0.zip to D:\MySQL\
3.mkdir build_x86 && pushd build_x86
4.cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=10.0.17134.0 -DWITH_BOOST=..\boost_1_67_0 ..\src
5.msbuild /p:Configuration=Debug;Platform=Win32 build_x86\MySQL.sln /t:Rebuild /m /p:BuildInParallel=true
[5 Nov 2018 9:48] Quella Zhang
Sorry for the wrong repro steps, that new one:
1.git clone https://github.com/mysql/mysql-server.git D:\MySQL\src
2.it's rely on boost 1.67,so extract boost_1_67_0.zip to D:\MySQL\
3.mkdir build_x64 && pushd build_x64
4.cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_SYSTEM_VERSION=10.0.17134.0 -DWITH_BOOST=C:\boost_1_67_0\x64 ..\src
5.msbuild /p:Configuration=Release;Platform=x64 build_x64\MySQL.sln /t:Rebuild /m /p:BuildInParallel=true
[5 Nov 2018 21:22] Miguel Solorzano
git and cmake

Attachment: 93077.txt (text/plain), 21.51 KiB.

[5 Nov 2018 21:30] Miguel Solorzano
Thank you for the bug report.
d:\MySQL\src>msbuild /p:Configuration=Release;Platform=x64 MySQL.sln /t:Rebuild /m /p:BuildInParallel=true > build.txt

--------cut-------------------

         d:\mysql\src\plugin\group_replication\include\pipeline_interfaces.h(304): warning C4267: 'argument': conversion from 'size_t' to 'ulong', possible loss of data (compiling source file D:\MySQL\src\plugin\group_replication\src\udf\udf_write_concurrency.cc) [d:\MySQL\src\plugin\group_replication\group_replication.vcxproj]
         d:\mysql\src\plugin\group_replication\src\udf\udf_write_concurrency.cc(105): warning C4244: 'initializing': conversion from '__int64' to 'uint32_t', possible loss of data [d:\MySQL\src\plugin\group_replication\group_replication.vcxproj]
         d:\mysql\src\plugin\group_replication\src\udf\udf_write_concurrency.cc(145): warning C4244: '=': conversion from '__int64' to 'uint32_t', possible loss of data [d:\MySQL\src\plugin\group_replication\group_replication.vcxproj]
         d:\mysql\src\plugin\group_replication\src\udf\udf_write_concurrency.cc(163): warning C4267: '=': conversion from 'size_t' to 'unsigned long', possible loss of data [d:\MySQL\src\plugin\group_replication\group_replication.vcxproj]
         d:\mysql\src\plugin\group_replication\include\pipeline_interfaces.h(304): warning C4267: 'argument': conversion from 'size_t' to 'ulong', possible loss of data (compiling source file D:\MySQL\src\plugin\group_replication\src\services\notification\impl\gms_listener_test.cc) [d:\MySQL\src\plugin\group_replication\group_replication.vcxproj]

    3191 Warning(s)
    0 Error(s)

Time Elapsed 00:53:29.14

d:\MySQL\src>runtime_output_directory\Release\mysqld.exe --version
d:\MySQL\src\runtime_output_directory\Release\mysqld.exe  Ver 8.0.13 for Win64 on x86_64 (Source distribution)

d:\MySQL\src>
[6 Nov 2018 7:04] Miguel Solorzano
I compiled with different cmake options, will try with options provided.
[6 Nov 2018 11:24] Umesh Shastry
Thank you for the feedback.
I'm not seeing any errors at my end on Win7 with VS 2017.
Joining the build log shortly.

regards,
Umesh
[6 Nov 2018 11:25] Umesh Shastry
Build log..

Attachment: 93077_Win7.results (application/octet-stream, text), 1.03 MiB.

[6 Nov 2018 17:28] Jan Kneschke
For the 1st, the fix in router/src/router/include/mysqlrouter/uri.h is to use

  #include <stdexcept>

instead of 

  #include <exception>

For the 2nd, the remove the "#define getpid GetCurrentProcessId" in router/src/logging/registry.cc as getpid() already exists in the windows sdk's headers.
[7 Nov 2018 7:58] Umesh Shastry
Thank you Jan Kneschke, I see in 8.0.13 src that 1st issue has been fixed

S/#include <stdexcept>/#include <exception>/ in router/src/router/include/mysqlrouter/uri.h

but router\src\harness\src\logging\registry.cc has still #define getpid GetCurrentProcessId

Verifying for now post Jan's earlier note.
[8 Nov 2018 10:07] Quella Zhang
Thanks for your attention! Sorry for the confusion, I use unreleased VS complier vctoolset, the next released VS will have this behavier.
I apply patch for the latest version e4924f3 on github and MySQL builds successfully. Waiting for your latest version.:)
[8 Nov 2018 10:14] Quella Zhang
My workaround, I am not sure if it is correct, but it does work.

Attachment: mysql_c2039.patch (application/octet-stream, text), 2.38 KiB.

[13 Nov 2018 18:50] Paul Dubois
Posted by developer:
 
Fixed in 8.0.14.

Corrections were made to enable successful builds under Visual Studio
on Windows.