1. Compile and use MySQL in LinuxC LanguageAPIProgramError:
GCC testmysql. c
Pp. c :(. Text + 0x11): Undefined reference to 'mysql _ init'
Pp. c :(. Text + 0x55): Undefined reference to 'mysql _ real_connect'
Pp. c :(. Text + 0x65): Undefined reference to 'mysql _ error'
Pp. c :(. Text + 0x90): Undefined reference to 'mysql _ close'
Collect2: LD returned 1 exit status
The reason is that the mysqlclient library is not linked during compilation.
Correct Solution: GCC testmysql. C-lmysqlclient
2. the following error occurs during compilation: Fatal error: mysql. h: no such file or directory.
But in the source file # include <mysql. h> what is going on?
Find out where the mysql. h file is located,
Locate mysql. h
/Usr/include/MySQL. h
It is not in the include directory, so change # include <mysql. h> in the source file to # include <MySQL/musql. h>.
OK.