Compile mysqldb in Windows

Source: Internet
Author: User

I want to compile mysqldb on my own.

First, configure a compilation environment. My operating system is Windows XP SP2 and Python 2.5.1. Python is a binary version directly downloaded from python.org. This version is compiled using vc2003 (vc7.1). Therefore, the corresponding Python extension must be compiled using the VC version (mingw can also be used, however, there may be some problems, because mingw uses msvcrt. DLL, while Python 2.5 uses msvcrt71.dll. It is said that the next specs file of mingw needs to be modified, but it is not quite clear ). If you directly install Visual Studio. NET 2003, it's easy. However, if your machine is not installed with this version of VC, or you have installed only VC toolkit 2003, you need to do something yourself. For details, refer to the two links included in my previous article.

Next, record the installation process of mysqldb. Download the source code of mysqldbfrom http://sourceforge.net/projects/mysql-python. the download is 1.22. In addition, MySQL header files and library files are required during installation. MySQL 5.1.22 is installed on my machine. Decompress the mysqldb code, enter the corresponding directory, execute Python setuo. py install, and then... an error occurs. After reading the error message: windowserror: [Error 2], this is a Windows system error code. Run net helpmsg 2 and check the Code 2. The error is: the system cannot find the specified file. When viewing the python error message, the corresponding key value cannot be found when you open the registry. I checked the code and found it at the site. the CFG configuration file contains the following line: registry_key = software/MySQL AB/MySQL Server 5.0, changed to registry_key = software/MySQL AB/MySQL Server 5.1, and then built again, sure enough, I went down. However, a series of VC compilation errors are thrown, which is roughly as follows:

D:/program files/Microsoft platform SDK for Windows XP SP2/include/winsock2.h (2178): Error c2375: 'getservbyname': redefinition; different linkage D: /program files/Microsoft platform SDK for Windows XP SP2/include/Winsock. H (867): See Declaration of 'getservbyname'

I am familiar with this error. Winsock. h and winsock2.h must be mixed in the program. I checked _ mysql. C and found two rows:

# Include <windows. h>
# Include <config-win.h>

Windows. H is a header file in the Platform SDK. This file will contain Winsock. h, and the config-win.h, this file is a MySQL header file, MySQL 5.1 This file will contain winsock2.h (Ha, it is estimated that 5.0 of the previous MySQL contains Winsock. h, I'll check it later), so it's messy during compilation.

Next is simple, I put the config-win.h # include <winsock2.h> into # include <Winsock. h>, then compile, OK!

However, I think it is not good to change the MySQL file. I decided to restore it and put _ MySQL. h # include <windows. h> comment out this line and compile it again. Well, OK. This is still not perfect. The information on the screen is displayed, and the Winsock library file wsock32.lib is used for linking. For a person like me, I still want to continue :)

Check the code again. In setup_windows.py, change libraries = ['kernel32', 'advapi32', 'wsock32', client] to libraries = ['kernel32', 'advapi32 ', 'ws2 _ 32', client], re-compile it. Well, I'm satisfied!

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.