Mam sobie pliczek o takiej treści:
#include <stdlib.h>
#include <stdio.h>
#include "mysql.h"
int main (int argc, char *argv[]){
MYSQL *conn_ptr
conn_ptr = mysql_init(NULL);
if (!conn_ptr){
fprintf(stderr, "mysql_init failed\n");
return EXIT_FAILURE;
}
conn_ptr = mysql_real_connect(conn_ptr, "localhost", "xxx", "xxx", "xxx", 0, NULL, 0);
if (conn_ptr){
printf("Connection success\n");
} else {
printf("Connection failed\n");
}
mysql_close(conn_ptr);
return EXIT_SUCCESS;
}
i teraz przy próbie kompilacji tego poleceniem
gcc -I/usr/local/mysql/include/mysql mysql.c -L/usr/local/mysql/lib/mysql -lmysqlclient -o mysql
otrzymuje coś takiego
mysql.c: In function `main':
mysql.c:9: error: syntax error before "conn_ptr"
mysql.c:10: error: `conn_ptr' undeclared (first use in this function)
mysql.c:10: error: (Each undeclared identifier is reported only once
mysql.c:10: error: for each function it appears in.)
Jeżeli za linijką MYSQL *conn_ptr postawie średnik, to kompiluje mi się to, ale przy próbie odpalenia kończy się na czymś takim:
./mysql: error while loading shared libraries: libmysqlclient.so.12: cannot open shared object file: No such file or directory
No i teraz pytanie, co można z tym zrobić [sciana]