Compiling and Linking

Before we delve into the various functions that you can use for interacting with MySQL, let's spend a few moments studying the structure of the sample code that we will create to demonstrate them. We will pay attention to compiler options and the means of linking to the library and include what our programs require.

Our code will consist of the following source files:

  • main.c, the main program that we will use to demonstrate the API

  • common.c, in which we will define common functions, such as for connecting to a MySQL server

  • common.h, a header file that contains prototypes for those common functions

  • The MySQL header files and client library

  • stdio.h, the library of standard input/output routines

You will need to ensure that the ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.