问题
After creating a solution with cmake, I am being put face to face with 1400 errors in Visual Studio during build. The main problem is, it seems no one compiles the connector, and just uses the precompiled library for their projects, more so on Windows. Here are some of errors, it seems timespec is being redefined one more time, first of all in ,and then a second time in my_global.h, errors and definitons below.
So the question is, how the hell do I fix 1400 errors?
Or at least, some advice how to get rid of redefinition would be GREAT!
time.h #ifndef _CRT_NO_TIME_T struct timespec { time_t tv_sec; // Seconds - >= 0 long tv_nsec; // Nanoseconds - [0, 999999999] }; #endif my_global.h
struct timespec {
union ft64 tv;
/* The max timeout value in millisecond for native_cond_timedwait */
long max_timeout_msec;
};
Error C2011 'timespec': 'struct' type redefinition (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\mysys\my_mess.c) mysys c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 660
Error C2039 'tv': is not a member of 'timespec' (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\mysys\my_malloc.c) mysys c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 681
Error C2227 left of '->tv' must point to class/struct/union/generic type (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\libmysql\authentication_win\handshake.cc) auth_win_client c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 681
Error C2227 left of '->max_timeout_msec' must point to class/struct/union/generic type (compiling source file C:\Users\DDubinin\Downloads\mysql-connector-c-6.1.6-src\libmysql\authentication_win\plugin_client.cc) auth_win_client c:\users\ddubinin\downloads\mysql-connector-c-6.1.6-src\include\my_global.h 682
回答1:
I'll close this issue, managed to compile the source with an older ,VS2013 x64, version of Visual Studio, and CMake 4.3.1 ...
It seems, the new changes in Visual Studio 2015 are breaking the C connector source code, I hope that MySQL team will fix this in a future release.
回答2:
i used mysql server code(i.e. mysql-5.7.13.zip) and compiled the MySQL Connector/C from it.
来源:https://stackoverflow.com/questions/34091321/compiling-mysql-connector-with-visual-studio-2015-win64