Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




Table of Contents | Next

Chapter 2. Compiling MySQL Applications


The core task of compiling a MySQL application is to link in the client library. First, you must ensure to include the MySQL header file as in the following example.

#include "mysql.h"

int main()
{
//my application
}

To compile, you must specify the location of the header and library. The following example illustrates the point using gcc.

gcc -I/path_to_mysql/include/mysql -L/path_to_mysql/lib/mysql
 myprogram.c -lmysqlclient

If you get an error that floor is an undefined symbol, you will need to link the math library with -lm. If you are using Solaris, you will get several socket undefined symbol errors. In this case, you need to link the socket libraries with -lnsl -lsocket. So for a full example:

gcc -I/path_to_mysql/include/mysql -L/path_to_mysql/lib/mysql
 myprogram.c -lmysqlclient -lm -lnsl -lsocket

After linking your program, the executable may be quite large. In this situation you need to strip the resulting application. Note that you will not be able to extract debugging information after stripping because the debug symbols are removed. The act of removing this additional information can be accomplished in one of two ways. If your linker supports the option, you can pass it -s on the command line to automatically remove excess information. The alternate method is to use the utility strip if your system has it installed. They both should accomplish the same thing. So to add to the above example, it should be:

gcc -s -I/path_to_mysql/include/mysql -L/path_to_mysql/lib/mysql
 myprogram.c -lmysqlclient -lm -lnsl -lsocket

Table of Contents | Next



With any suggestions or questions please feel free to contact us