0
I’m learning to use the Mysql, but I had some problems compiling a program, in C, using the resources of Mysql. Follows 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 the same, using direct commands from the terminal and had no problems, then, I am sure q the installation occurred accordingly.
In order to use the resources of mysql in C, I installed the 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. Below 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 directories of the mysql, however, I don’t know how to make it include the directories correctly.
How do I correctly include the directories of mysql?
Got it! I was able to compile, with your tip. Thanks for the clarification.
– Roger