MySQL comes with a special script called mysql_config . It provides you with useful information for compiling your MySQL client and connecting it to the MySQL database server.
Pass --libs option - Libraries and parameters needed to communicate with the MySQL client library.
$ mysql_config --libs
Typical Output:
-L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto
Now you can add this to your compilation / link line:
gcc -o mysql-test MySQL-Test.c $(mysql_config --libs)
codaddict
source share