gcc wont compile and run MySQL C libraries

后端 未结 7 587
不知归路
不知归路 2021-02-03 14:20
#include 
#include 

int main(int argc, char **argv)
{
  printf(\"MySQL client version: %s\\n\", mysql_get_client_info());
}

7条回答
  •  感情败类
    2021-02-03 14:50

    MySQL comes with a special script called mysql_config. It provides you with useful information for compiling your MySQL client and connecting it to MySQL database server.

    Pass --libs option - Libraries and options required to link 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 compile/link line:

    gcc -o mysql-test MySQL-Test.c $(mysql_config --libs)
    

提交回复
热议问题