Use Lccwin32 for MySQL development.

Source: Internet
Author: User
Tags header include modify mysql reference
Mysql
Use Lccwin32 for MySQL development.

Current Author: Wang Mei (HeartIcy@163.com)
Date Created: February 11, 2003
Revised version: 1.1

I am a student, maybe I will always be a student in this life. ' Cause I never thought I'd be
For a generation of gurus!! ^^|| Just because I am a student, the so-called I need to pick the standard support integrity and
Easy to get free compiler. LCCWIN32 support for the standard is very high, and scalability is also
Strong. Usually follow the development library written by C89 or C99 standard, the header file part basically does not have to modify, only
You can use the format of the library (. lib) file to convert it.

I'll show you how to develop MySQL through Lccwin32 with a simple example. Emphasis on the ground
Side is not part of the code, but the compiler's configuration lccwin32 itself the IDE editor part of the Chinese
Support is equal to 0 and there is a bug on the header file reference path setting, we have to handle it manually! This is
I think the importance of writing this note. (I never thought I'd write something about what the article was, and I haven't
That weight. ^^|| )

I just mentioned the Lccwin32 editor has bugs, we need to manually modify the compiler generated makefile
Files cannot be compiled at all.

Assuming you are using the default path, the Lccwin32 editor automatically generates makefile files that should be wrapped in
Contains similar segments:

Cflags=-i "C:\lcc\include"-o-p6-unused-ansic

If we add a long file reference path directly from the editor, we will create an error, so we add it manually
The path becomes the form below:

Cflags=-i "C:\lcc\include"-i "C:\mysql\include"-o-p6-unused-ansic

Ok! The first problem header file reference is resolved.

Now let's get to the next problem library file (. lib). Windows MySQL library file with Vc5
First, we need to use the library conversion tool that comes with lccwin32 to transform. After conversion, LCCWIN32 can
To properly identify this library file. So the important question is how we can introduce the library file. In Lccwin32, we
You can use two methods, the first of which is to knock the storage name directly from the library reference of the editor;
One is to use compiler preprocessor pseudo instruction #pragma lib "library". I recommend the second type,
Because we need the debug library file to Debuger in the development process, the actual release in order to efficiency we
You will need to build the final release file with opt edition and set it directly in the editor in the LCCWIN32 environment.
It is unwise to place!

Now that we've solved the references to header and library files, there's actually no problem. A simple Jane
Examples of the list are as follows:

#pragma lib <libmysql.lib>
#include <stdio.h>
#include "mysql.h"

MYSQL *mydata;

int main (int argc, char *argv[])
{
Char userid[20];
strcpy (userid, "root"); Account
Char password[20];
strcpy (password, ""); Password
Char host[20];
strcpy (host, "localhost"); Host
Char dbname[10];

strcpy (dbname, "test"); Database
if ((MyData = Mysql_init ((mysql*) 0)) &&
Mysql_real_connect (MyData, host, userid, password, dbname, Mysql_port, NULL, 0))
printf ("Mysql ready\n");
Else
Exit (0);
Mysql_close (MyData);
return 1;
}

If this article is completely followed, a 3.03kb or 13.03kb (debuger) executable file has been generated. By the way,
I don't know, there's still competition. The resulting executable file volume is not. MySQL official routine with Lccwin32 compiled volume
VC generated only 1/5 of the size of the executable file!

* * Applicable scope mysql3.23.x above (www.mysql.com)
* * Lccwin32 more than 3.2 (www.cs.virginia.edu/~lcc-win32/)

* * If you have any questions, please email HeartIcy@163.com and discuss with me. Good luck!

* * This document is issued in accordance with the Free Software Foundation General Document License Agreement * *


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.