Bug #78282 MySQL 5.6 fails to compile with Visual Studio 2015
Submitted: 31 Aug 2015 5:37 Modified: 11 Jan 2016 8:49
Reporter: Kieron Briggs Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.6 OS:Windows
Assigned to: CPU Architecture:Any

[31 Aug 2015 5:37] Kieron Briggs
Description:
Building under Visual Studio 2015 fails with (~77 instances of) the error message:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt\stdio.h(1927): fatal error C1189: #error:  Macro definition of snprintf conflicts with Standard Library function declaration (compiling source file C:\Users\kbriggs\projects\thirdparty\mysql-server\strings\bchange.c) [C:\Users\kbriggs\projects\thirdparty\mysql-server\x64\strings\strings.vcxproj]

How to repeat:
1. Install Visual Studio 2015 with applicable C++ components
2. Install CMake 3.1
3. Configure, e.g.: C:\Users\kbriggs\projects\thirdparty\mysql-server>"\Program Files (x86)\CMake 3.1\bin\cmake.exe" -Bx64 -G "Visual Studio 14 2015 Win64" -H. -DWITH_INNOBASE_STORAGE_ENGINE=yes -DWITH_PARTITION_STORAGE_ENGINE=yes -DWITH_PERSCHEMA_STORAGE_ENGINE=no -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DINNODB_PAGE_ATOMIC_REF_COUNT=no -Wno-dev
4. Build: C:\Users\kbriggs\projects\thirdparty\mysql-server>msbuild /nologo x64\sql\mysqld.vcxproj /p:Configuration=Release
[31 Aug 2015 6:06] Kieron Briggs
https://github.com/kbriggs/mysql-server/commit/8ec790afb233daadb6a7b2072c22f0f1d84af05d gets past the snprintf error, new error is (~14 instances of):

C:\Users\kbriggs\projects\thirdparty\mysql-server\include\my_pthread.h(102):error C2011: 'timespec': 'struct' type redefinition (compiling source file C:\Users\kbriggs\projects\thirdparty\mysql-server\vio\viosslfactories.c) [C:\Users\kbriggs\projects\thirdparty\mysql-server\x64\vio\vio.vcxproj]
[2 Sep 2015 0:29] Kieron Briggs
Some more suggested changes: https://github.com/mysql/mysql-server/compare/5.6...kbriggs:topic-vs2015

With these changes, MySQL compiles under VS2015, at least on my system, and runs, although I have done only the most cursory of testing. I've also not checked whether the changes break building on other compilers/systems. Most of the changes are pretty straightforward, except 403a83e which I'm not at all confident about.
[8 Sep 2015 12:50] Chiranjeevi Battula
Hello Kieron Briggs,

Thank you for the bug report.
Could you please provide "CMakeLists.txt" file to confirm this issue at our end?

Thanks,
Chiranjeevi.
[22 Sep 2015 8:28] Jon Olav Hauglid
Verified. Thanks for the bug report!
[6 Nov 2015 0:09] Kieron Briggs
Allow compilation on Visual Studio 2015

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 5.6...kbriggs topic-vs2015.patch (application/octet-stream, text), 15.55 KiB.

[6 Nov 2015 0:11] Kieron Briggs
The above contribution is the same as the changes on the branch linked earlier; the same caveats about the amount of testing done apply. Apologies for the delay in getting the OCA sorted.
[11 Jan 2016 8:44] Ajo Robert
Posted by developer:
 
Hello  Kieron,

We have utilized some part of your contribution while fixing the issue reported.
Appreciate the effort taken for this contribution.

Thank you!
-Ajo.
[11 Jan 2016 8:49] Ajo Robert
Issue is fixed as part of internal Bug#21770366.
Fix will be available in 5.6.29.
[14 Jan 2016 0:24] Naoki Inada
When MySQL Connector/C supports VC 2015 will be released?

Python 3.5 was released on September 2015.
It is built with VC 2015 and cannot use MySQL Connector/C for months.
[1 Jun 2016 14:20] Steve Northup
Any update on this?  I would love to see a standard build that that works with VS 2015.  I have recently switched over and now I can't use my C++ Connector code.
[13 Jun 2016 12:44] Ståle Deraas
Posted by developer:
 
Steve,

What version are you using? As Ajo mentions above, this is fixed in 5.6.29.

Staale
[13 Jun 2016 13:20] Ståle Deraas
Posted by developer:
 
Or did you ask about Connector/C ?
[13 Jun 2016 13:25] Steve Northup
I was using the most recent GA release at the time.  I believe it was C++ Connector 1.1.7?  Either way I have switched to SQLAPI++ at this point, it worked right away for me.