S
S
spy452422018-07-06 10:21:27
MySQL
spy45242, 2018-07-06 10:21:27

Why doesn't the C code compile with a database connection?

On a remote server (without admin rights) I'm trying to compile such a simple code from the primer:

#include <my_global.h>
#include <mysql.h>
int main(){
  MYSQL conn;
  mysql_init(&conn);
  mysql_real_connect(&conn, "localhost", "user", "passwd", "base", 0, NULL, 0);
  mysql_query(&conn, "SELECT * FROM auth");
  mysql_close(&conn);
}

It swears that it does not find the mysql.h and my_global.h files
. There is one in the /usr/include/mysql/mysql.h folder.
I tried in different ways and write like this:
#include /include/mysql/mysql.h>
And point to the path to the file when compiling the program, but all attempts failed.
In general:
either this
error: my_global.h: No such file or directory
or
/usr/bin/ld: cannot find -lmysqlclient
Compiling gcc

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PrAw, 2018-07-06
@spy45242

Most likely, the administrator did not install a package with header files for development.
Specifically, in this case, libmysqlclient-dev is required, as it is called in debian / ubuntu
How to get around? download by hand, decompose locally, edit paths, but here I am not strong.

R
res2001, 2018-07-06
@res2001

Apparently you need to connect the headings like this: Use tags - it's impossible to read.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question