I'm learning how to use MySql , but I had some problems compiling a program in C using MySql . Here are the errors below:
gcc: error: Usage:: No such file or directory
gcc: error: [OPTIONS]: No such file or directory
gcc: error: Options:: No such file or directory
gcc: error: [-I/usr/include/mysql: No such file or directory
gcc: error: [-I/usr/include/mysql: No such file or directory
gcc: error: [-L/usr/lib/x86_64-linux-gnu: No such file or directory
gcc: error: [-L/usr/lib/x86_64-linux-gnu: No such file or directory
gcc: error: [/usr/lib/mysql/plugin]: No such file or directory
gcc: error: [/var/run/mysqld/mysqld.sock]: No such file or directory
gcc: error: [0]: No such file or directory
gcc: error: [5.7.13]: No such file or directory
gcc: error: [-L/usr/lib/x86_64-linux-gnu: No such file or directory
gcc: error: VAR: No such file or directory
gcc: error: is: No such file or directory
gcc: error: one: No such file or directory
gcc: error: of:: No such file or directory
gcc: error: pkgincludedir: No such file or directory
gcc: error: [/usr/include/mysql]: No such file or directory
gcc: error: pkglibdir: No such file or directory
gcc: error: [/usr/lib/x86_64-linux-gnu]: No such file or directory
gcc: error: plugindir: No such file or directory
gcc: error: [/usr/lib/mysql/plugin]: No such file or directory
gcc: error: unrecognized command line option ‘--cflags’
gcc: error: unrecognized command line option ‘-fno-omit-frame-pointer]’
gcc: error: unrecognized command line option ‘--cxxflags’
gcc: error: unrecognized command line option ‘-fno-omit-frame-pointer]’
gcc: error: unrecognized command line option ‘--libs’
gcc: error: unrecognized command line option ‘--libs_r’
gcc: error: unrecognized command line option ‘--plugindir’
gcc: error: unrecognized command line option ‘--socket’
gcc: error: unrecognized command line option ‘--port’
gcc: error: unrecognized command line option ‘--libmysqld-libs’
gcc: error: unrecognized command line option ‘--variable=VAR’
These errors appeared in the ubuntu terminal, after I gave the command to compile the program:
~$ gcc teste.c -o teste $(mysql_config -libs)
To use MySql I installed mysql-server and mysql-client:
~$ sudo apt-get install mysql-server mysql-client
The installation went well and successfully. To test I created tables and inserted elements in it, using direct commands through the terminal and I had no problems, so I'm sure the installation occurred accordingly.
In order to use mysql resources in C, I installed libs from the following command:
apt-get install libmysqlclient-dev
Apparently this installation also occurred successfully, but when I compile the test program, the errors I mentioned above occur. Here is the program:
#include "stdio.h"
#include "stdlib.h"
#include <mysql/mysql.h>
void main(void)
{
MYSQL *hMsql = null;
mysql_init(hMsql);
}
The first error indicates that the compiler is not finding the mysql directories, however, I'm not sure how to get it to include the directories correctly.
How do I correctly include the mysql directories ?