Bug #75502 | Error compiling mySQL C-Client Program | ||
---|---|---|---|
Submitted: | 14 Jan 2015 10:46 | Modified: | 16 Feb 2015 18:11 |
Reporter: | Philippe Bellamit | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / C | Severity: | S1 (Critical) |
Version: | 6.1.5 | OS: | Windows (Win 7) |
Assigned to: | CPU Architecture: | Any | |
Tags: | Compilation, my_global.h |
[14 Jan 2015 10:46]
Philippe Bellamit
[14 Jan 2015 15:26]
Philippe Bellamit
Original my_global.h in Connector-C include directory
Attachment: my_global.h (application/octet-stream, text), 24.91 KiB.
[14 Jan 2015 15:27]
Philippe Bellamit
Related to winsock2.h adherence
[20 Jan 2015 6:27]
Philippe Bellamit
Do not happen using the v32-x86 version of Client 6.1.5. Only for the v64 version. Maybe related to DMC Compiler wich is only 32b ? Anyway, there is a conflict with windows includes. Regards
[20 Jan 2015 14:42]
Igor Solodovnikov
Hello Philippe, I think you should use 32-bit version of Connector/C with 32-bit compiler. And please can you elaborate a bit on the conflict with windows includes? I don't think I fully understand what do you mean saying there is a conflict.
[21 Jan 2015 11:00]
Philippe Bellamit
The conflict comes from different definitions of type uint32 : 1) In my_config.h, line 363, there is: #define SIZEOF_INT 4 2) Thus in my_global.h, in C:\Program Files (x86)\MySQL\MySQL Connector.C 6.1\include, there is lines 636-638): #if SIZEOF_INT == 4 typedef unsigned int int32; Then the compiler stops saying it was already defined as long. I will switch to the 32b version, and check.
[21 Jan 2015 16:33]
Igor Solodovnikov
Hello Philippe, I did some tests with your example source code. With VS2013 and VS2010 it complies without errors. The reason for this is that winsock2.h used in Visual Studio 2010 does not define any int32 typedefs. WinSock2.h version from Visual Studio 2013 defines '__int32' but does not use 'int32'. So there is no conflict if you use more or less fresh microsoft compiler and include files on Windows. Thus the question is what version of winsock2.h is on your include patch and if you can update it.
[16 Feb 2015 18:10]
Philippe Bellamit
I have corrected my problem switching from DMC that was crearly obsolete to Visual Studio and standard MS SDK. It has been a bit of a fight to find the correct libraries to link to in x64 mode, but ended working. However there is a (minor) bug in my_config.h which redefines differently "inan" after including math.h. In addition, the static client has incorrect external definitions. Thus the correct include sequence is: #include <winsock2.h> #include <windows.h> #include <sys\types.h> // Bug in mysql.h definitions #ifndef strnicmp /* from string.h **************/ #define strnicmp _strnicmp #define stricmp _stricmp #define strdup _strdup /* from stdlib.h **************/ #define putenv _putenv /* from direct.h *************/ #define getcwd _getcwd #define chdir _chdir /* from stdio.h **************/ #define fdopen _fdopen #define fileno _fileno #endif // #include <my_config.h> /* Included by my_global.h */ #include <my_global.h> #include <mysql.h> ... and in addition, it is necessary to add oldnames.lib in link libraries. Thanks for your assistance.
[16 Feb 2015 18:11]
Philippe Bellamit
Solved (but not easily !)