Bug #92643 Build MySQL Connector\ODBC 8.0 on Windows
Submitted: 2 Oct 2018 21:46 Modified: 3 Oct 2018 18:05
Reporter: Swikriti Jain Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:8.0, 8.0.12 OS:Windows
Assigned to: CPU Architecture:Other

[2 Oct 2018 21:46] Swikriti Jain
Description:
Hi,

I am trying to build MySQL ODBC driver 8.0 by following the given link: 
https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-installation-source-windows.htm...

I downloaded all the prerequisites and I am using Visual Studio 2015 with MySQL Server source code 8.0. I built the connector using cmake command (cmake -G "Visual Studio 14 2015 Win64") and now I am trying to build the solution but I am getting some errors because of MEM_ROOT and CHARSET_INFO struct.

I had some similar redefinition issue about struct 'timespec', but I was able to solve it by adding 'HAVE_STRUCT_TIMESPEC' to Preprocessor Definitions. I am not sure how to overcome these errors.

The errors are:

2>c:\users\dms\downloads\working2015-5.7\mysql-connector-odbc-master\include/sys_main.h(111): error C2371: 'MEM_ROOT': redefinition; different basic types
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(161): note: see declaration of 'MEM_ROOT'
2>c:\users\dms\downloads\working2015-5.7\mysql-connector-odbc-master\include/sys_main.h(478): error C2371: 'CHARSET_INFO': redefinition; different basic types
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(70): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(70): error C2227: left of '->number' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(73): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(73): error C2227: left of '->mbminlen' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(74): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(74): error C2227: left of '->mbmaxlen' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(161): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(161): error C2227: left of '->number' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(172): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(172): error C2227: left of '->mbmaxlen' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(417): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(417): error C2227: left of '->mbminlen' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(417): error C2227: left of '->mbmaxlen' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(528): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(528): error C2227: left of '->cset' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(528): error C2227: left of '->mb_wc' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(529): error C2027: use of undefined type 'CHARSET_INFO'
2>  C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h(298): note: see declaration of 'CHARSET_INFO'
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(529): error C2227: left of '->cset' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(529): error C2227: left of '->wc_mb' must point to class/struct/union/generic type
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(536): error C3536: 'mb_wc': cannot be used before it is initialized
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(536): error C2100: illegal indirection
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(558): error C3536: 'wc_mb': cannot be used before it is initialized
2>C:\Users\dms\Downloads\Working2015-5.7\mysql-connector-odbc-master\util\stringutil.cc(558): error C2100: illegal indirection

How to repeat:
Build solution using: devenv.com MySQL_Connector_ODBC.sln /build Release
[2 Oct 2018 22:24] Swikriti Jain
Build Output

Attachment: build_output.txt (text/plain), 82.89 KiB.

[3 Oct 2018 7:11] MySQL Verification Team
Hello Swikriti,

Thank you for the report.
Observed similar issue with VS2017.

regards,
Umesh
[3 Oct 2018 8:30] MySQL Verification Team
HI Swikriti,

Discussed internally with Bogdan(our ODBC lead Developer), confirmed that that this is an expected behavior since it was trying to build dynamic version and per manual -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE option should be provided to the cmake. I quickly tried at my end and confirmed that there is no issue in build.

## Win7 + VS 2017 + mysql-connector-odbc-8.0.12-src.tar.gz from https://dev.mysql.com/downloads/connector/odbc/
cmake -G "Visual Studio 15 2017 Win64" -DMYSQL_DIR=D:\MySQL\mysql-8.0.12 -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE -DSTATIC_MSVCRT:BOOL=FALSE
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com" MySQL_Connector_ODBC.sln /build Release

Joining build log shortly.

regards,
Umesh
[3 Oct 2018 8:30] MySQL Verification Team
Build log..

Attachment: 92643_build.log (application/octet-stream, text), 33.08 KiB.

[3 Oct 2018 17:41] Swikriti Jain
Hi Umesh,

Thanks for the reply! I tried using the arguments that you have provided but now I am getting some other error:

I did "cmake -G "Visual Studio 14 2015 Win64" -DMYSQL_DIR="C:\Program Files\MySQL\MySQL Server 8.0" -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE -DSTATIC_MSVCRT:BOOL=FALSE"

and then "devenv.com MySQL_Connector_ODBC.sln /build Release"

I am attaching both cmake and build logs.

Thanks
Swikriti
[3 Oct 2018 17:42] Swikriti Jain
Build Output

Attachment: buildOutput.txt (text/plain), 78.78 KiB.

[3 Oct 2018 17:47] Swikriti Jain
Cmake output

Attachment: CmakeOutput.txt (text/plain), 15.32 KiB.

[3 Oct 2018 18:05] Swikriti Jain
Hi,

I was able to build the solution successfully by changing my_bool to bool, but it will be good to know how to fix it without changing the code.

Thanks for the help so far.