Accessing MySQL from C
wmoran at potentialtech.com
Tue Apr 20 12:22:43 PDT 2004
Derrick Ryalls wrote:
>>In the last episode (Apr 20), Derrick Ryalls said:
>>>I am trying to write a little program that will talk to my existing
>>>mysql db server (4.1.1), but am having compile issues.
>>You need -I/usr/local/include/mysql on your compile line, and
>>-L/usr/local/lib/mysql on your link line.
>>gcc -I/usr/local/include/mysql -c sqltest.c
>>gcc -L/usr/local/lib/mysql -o sqltest sqltest.o -lmysqlclient
>>If you are compiling and linking in one step, you need both.
>>gcc -I/usr/local/include/mysql -L/usr/local/lib/mysql -o
>>sqltest sqltest.c -lmysqlclient
As a suggestion: consider creating a Makefile and using make to automate
the process. make isn't really that hard to use to automate building
simple programs, and it's almost necessary to keep the build process
for large programs working.
If you're not familiar with make, here's a good tutorial to start with:
More information about the freebsd-questions