Home > Software engineering >  How to use MySQL with Ubuntu ‘C’?
How to use MySQL with Ubuntu ‘C’?

Time:10-11

I am using Ubuntu Linux 20.04.2 and MySQL 8.0.30 but when I try to compile using a Linux Terminal command like: gcc -o program program.c ‘mysql_config —libs’ I get a message like: “Error: mysql. . No such file or directory”

It appears that gcc doesn’t recognize the directory where the ‘Include’ ( .h ) files are located. That is: ‘/usr/include/mysql’. I have tried several variations of the gcc command without success. There is probably a simple solution and I would appreciate any help.

CodePudding user response:

It's $(pkg-config --libs --cflags mysql...), replace the mysql... with the name of library.

CodePudding user response:

Thank you to those who answered my question. What seems to have solved the problem, is adding the -I option to the gcc command. I used: $ gcc -o progrm -I /usr/include/mysql program.c

  • Related