Mysql with C++ error: undefined reference to mysql_init

后端 未结 3 1791
眼角桃花
眼角桃花 2021-01-06 04:02
#include 
#include 

#include 


int main (int argc, char *argv[])
{

MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

         


        
相关标签:
3条回答
  • 2021-01-06 04:24

    Setting -> Compiler and debugger -> Search directories -> Linker then Add and insert /usr/lib/mysql/

    0 讨论(0)
  • 2021-01-06 04:25

    compile your app with the command bellow

    gcc -o test  -L/usr/lib/mysql -lmysqlclient test.c
    
    0 讨论(0)
  • 2021-01-06 04:33

    This is for Linux environments only:

    In "Project build options" > "Linker settings" Tab > Under "Other linker options" add -lmysqlclient

    enter image description here

    You will also need to add mysql-connector-c-6.1.3-linux-glibc2.5-x86_64/include/ in "Search directories" > "Compiler"

    enter image description here

    You will also need to add mysql-connector-c-6.1.3-linux-glibc2.5-x86_64/lib/ in "Search directories" > "Linker"

    enter image description here

    For windows:

    -lmysql

    MySQL Connector library can be found here: http://dev.mysql.com/downloads/connector/c/

    0 讨论(0)
提交回复
热议问题