Tag Archives: clang

[C]fatal error: mysql.h: No such file or directory

Environment: under the Linux distribution of windows system, Ubuntu 20.04.2 lts;

Problem Description: MySQL C API programming, after installing MySQL C development library, sudo apt install default libmysqlclient dev , compile version. C file: GCC version. C - O version. O
version. C is as follows:

#include <mysql.h>
#include <stdio.h>

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

        exit(0);
}

report errors:

version.c:1:10: fatal error: mysql.h: No such file or directory
    1 | #include <mysql.h>

Problem reason: no header file path parameter, unable to address
problem modification: Where is MySQL find mysql. H path: /usr/include/MySQL
recompile: GCC version. C - O version. O - I/usr/include/MySQL
report error again:

/usr/bin/ld: /tmp/ccEn7kBU.o: in function `main':
version.c:(.text+0x14): undefined reference to `mysql_get_client_info'
collect2: error: ld returned 1 exit status

Cause of the problem: no lib parameter is added, so the function cannot be referenced
problem modification: GCC version. C - O version. O - I/usr/include/MySQL - lmysqlclient
problem solving.