# Главная
# О библиотеке

# Выбор дистрибутива
преимущества Linux/UNIX | основные дистрибутивы | серверный Linux | BSD | LiveCDs | прочее

# Установка и удаление программ
общие вопросы | каталоги софта | специальные случаи

# Настройка и работа
установка, загрузчики | настройка Linux | консоль | файловые системы | процессы | шеллы, русификация, коммандеры | виртуальные машины, эмуляторы

# X Window и оконные менеджеры
настройка X Window | GNOME | KDE | IceWM и др.

# Работа с текстами
редакторы | офис | шрифты, кодировки и русификация | преобразования текстовых файлов | LaTeX, SGML и др. | словари

# Графика
GIMP | фото | обработка изображений | форматы графических файлов

# Сети, администрирование
общие вопросы | Dialup & PPP | брандмауэры | маршрутизация | работа в Windows-сетях | веб-серверы | Apache | прокси-серверы | сетевая печать | прочее

# Программирование
GCC & GNU make | программирование в UNIX | графические библиотеки | Tcl | Perl | PHP | Java & C# | СУБД | CVS | прочее

# Ядро
# Мультимедиа
# Интернет
# Почта
# Безопасность
# Железо
# Разное

# Linux HowTo (как сделать)
# Книги и руководства
# Материалы на английском языке


MySQL The World's Most Popular Open Source Database # Online shop | Site map |  
CompanyProductsSupport & ConsultingTraining & CertificationDownloadsDocumentation
  BooksArticlesMailing ListsPresentationsOther Sites  
Search the MySQL manual:
MySQL Manual
  • 2 Установка MySQL
    • 2.6 Заметки по операционным системам
      • 2.6.2 Примечания к Windows
        • 2.6.2.1 Запуск MySQL на Windows 95, 98 или Me
        • 2.6.2.2 Запуск MySQL на Windows NT, 2000 или XP
        • 2.6.2.3 Работа MySQL в среде Windows
        • 2.6.2.4 Соединение с MySQL на удаленной машине под Windows с использованием SSH
        • 2.6.2.5 Распределение данных в Windows между несколькими различными дисками
        • 2.6.2.6 Компиляция MySQL-клиентов в среде Windows
        • 2.6.2.7 Сравнительные характеристики MySQL под Windows и под Unix

Buy this Reference Manual in softcover from Barnes & Noble!

MySQL Reference Manual
Previous / Next / Up / Table of Contents

2.6.2.6 Компиляция MySQL-клиентов в среде Windows

В файлах исходных текстов следует перед `mysql.h' включить `windows.h':

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
#include <mysql.h>

Линковать свою программу можно либо с использованием динамической библиотеки `libmysql.lib', которая является просто оболочкой для загрузки `libmysql.dll' по требованию, либо со статической библиотекой `mysqlclient.lib'.

Отметим, что поскольку библиотеки mysqlclient компилируются как потоковые библиотеки, следует скомпилировать вашу программу так, чтобы была разрешена многопочность!

User Comments

Posted by Jacob Devore on Tuesday January 29 2002, @8:30am[Delete] [Edit]

I am trying to link with the mysqlclient.lib and
keep getting errors like these

mysqlclient.lib(libmysql.obj) : error LNK2001:
unresolved external symbol _WSAGetLastError@0

I'm running on win2k with vc6.

Posted by [email protected] on Friday February 8 2002, @7:54am[Delete] [Edit]

Yup, I have the same problem using the mingw compiler (gcc) under Win2k.

Posted by Thomas Koch on Sunday February 10 2002, @8:02am[Delete] [Edit]

I've the same Problem too. (LNK Error with
unresolved symbols in a VC++ 6.0 on Windows 98).
I had alredy try it to compile it multithreated
and to include the wondows.h in my application
but the problem remains. Can anyone give me a
good hint to solve this problem. (Is it necessary
to have a mysqlclient.lib compiled with the
VC++ ? or where one can get the source for the
library)

Posted by Dan Dickinson on Thursday February 21 2002, @8:46am[Delete] [Edit]

I solved some of those link problems (using gcc
on Win2K) with these options:
-lm -lwsock32 -luser32 -lgcc
However, I still get an unresolved _chkstk symbol
in mysqlclient.lib.

Posted by [name withheld] on Monday March 11 2002, @6:14pm[Delete] [Edit]

It took me a couple of hours to iron the problems
out, but I succeeded in compiling a client under
Microsoft Visual C++ version 6.0. mysql_com.h
causes problems with sockets unless winsock.h is
included beforehand. Also, VC++ included a library
that caused conflicts with mysqlclient.lib, which
I took care of with a directive to the linker to
ignore that library (I'm not at the lab anymore,
so I can't look up the exact name of that library;
if you run into the same problem I did, just add
the directive that the linker suggests when it fails).

Posted by Dinesh V. R. on Monday December 9 2002, @12:16am[Delete] [Edit]

the linker problem I have solved.
see
www.dvrsol.com/programming.html#mymingw
here you can download client library for mingw
compiler

Posted by Monaco Olivier on Thursday February 27 2003, @2:41am[Delete] [Edit]

Previous comment permit to compile a MySQL client using libmysql.dll file under GCC for Windows (Dev-C++). But if you want to use mysqlclient.lib you need more manipulation.

Tools to use :
- dlltool.exe which comes with GCC
- pexports.exe from http://starship.python.net/crew/kernr/mingw32/Notes.html for example

1) First you need to create de def file from your ntdll.dll :

pexports c:\winnt\system32\ntdll.dll > c:\mylibs\ntdll.def

This command line extract each exports from ntdll.dll and put its in ntdll.def. If you prefer more complex command line do

echo EXPORT > c:\mylibs\ntdll.def
nm c:\winnt\system32\ntdll.dll | grep " T _" | sed "s/.* T _//" >> c:\mylibs\ntdll.def

It's same.

2) You need to create a .a file for gcc from ntdll.dll and ntdll.def

dlltool --input-def c:\mylibs\ntdll.def --dllname ntdll.dll --output-lib c:\mylibs\libmyntdll.a

Don't name the .a file as libntdll.a because standard libs of GCC include libntdll.a. But this version seem to don't content chkstk function symbol...

3) Now configure your GCC (I'm using Dev-C++) :

Library directory to include :
c:\mylibs

Liker directives :
c:\mysql\lib\mysqlclient.lib -lws2_32 -lmsvcrt20 -lmyntdll

These directives permit you to incule mysqlclient.lib in link process which need libws2_32.a form Windows Socket API, libmsvcrt20.a because mysqlclient.lib was compiled with MS Visual C++ and libmyntdll.a for _chkstk function...

For moment I don't have tested all function of mysqlclient.lib to be sure of no errors but I'm think it's good :))

Good luck...

Note : your program need ntdll.dll (which is part of Windows NT/2000/XP), msvcrt20.dll and ws2_32.dll (which comes with Windows 2000/XP).

Olivier

Add your own comment.

Top / Previous / Next / Up / Table of Contents
# MySQL.com home | Site map | Contact us | Press | Jobs | Privacy policy | Trademark info | © 1995-2003 MySQL AB. All rights reserved.