skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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


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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search