Search the MySQL manual:

9.1.13 Building Client Programs

If you compile MySQL clients that you've written yourself or that you obtain from a third-party, they must be linked using the -lmysqlclient -lz option on the link command. You may also need to specify a -L option to tell the linker where to find the library. For example, if the library is installed in `/usr/local/mysql/lib', use -L/usr/local/mysql/lib -lmysqlclient -lz on the link command.

For clients that use MySQL header files, you may need to specify a -I option when you compile them (for example, -I/usr/local/mysql/include), so the compiler can find the header files.

To make the above simpler on Unix we have provided the mysql_config script for you. See section 4.8.10 mysql_config, Get compile options for compiling clients.

You can use this to compile a MySQL client by as follows:

CFG=/usr/local/mysql/bin/mysql_config
sh -c "gcc -o progname `$CFG --cflags` progname.c `$CFG --libs`"

The sh -c is need to get the shell to not threat the output from mysql_config as one word.

User Comments

Posted by Alexander Voropay on Tuesday January 28 2003, @12:33am[Delete] [Edit]

You should use "/usr/lib/mysql" path for libraries on RedHat Linux.

Posted by Raul Deschamps on Thursday March 6 2003, @11:08am[Delete] [Edit]

It would be great if you have a sort of RFC on the protocol.
the applications i develop for my company have to be cross platform, we work mostly under windows and macintosh.
For faster development, i dont use conventional compilers for my applications, for mac, i have to make a carbon version so it works with both OS X and OS 9, so the C compiler i use is codewarrior, and doesnt work with the mysql standard libraries (codewarrior can also compile for windows, so what i compile comes out for mac os 9, 10.2 and windows), and also, for SSL connections, i dont use openSSL, we use our own SSL classes, i have a SSL socket that supports SSL v1, 2 , 2-3 and 3 and TLS1, so, if i know the protocol for mysql, i would be able to build my own client library.

Add your own comment.