undefined symbol: mysql_real_connect
Bonjour,
J'ai fait pas mal de recherche mais je ne trouve pas ce qui coince.
Je crée une librairie C et j'appelle les fonctions à partir de python.
La fonction de connexion dans le fichier DataBaseAccess.c :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <my_global.h>
#include <mysql.h>
...
Mafonction * getDataFromId(int Id, Personnage * currentPersonnage) {
//Create and initialize a connection handle object
MYSQL connection;
if (mysql_init(&connection) == NULL) {
printf("Connection handle initialization failed !\n");
exit(1);
}
//Connect to MySQL server
if (mysql_real_connect(&connection, "localhost", "user", "password", "dbname", 3306, NULL, 0) != NULL) {
printf("Connection to remote MySQL server established\n");
} else {
printf("Connection attempt to remote MySQL failed !\n");
exit(1);
}
//Close the connection
mysql_close(&connection);
return 0;
} |
La ligne de commande de compilation :
Code:
gcc -O3 -I/usr/include/mysql -lmysqlclient -fPIC -g3 -o DataBaseAccess.o -c DataBaseAccess.c
Aucun problème à la compilation.
En ligne de commande python, je charge la librairie, puis j'appelle la fonction.
J'ai ce message d'erreur :
Code:
1 2 3 4 5 6 7
| ...
Lib = ct.cdll.LoadLibrary('../../lib/DataBaseAccess.so')
File "/usr/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: ../../lib/DataBaseAccess.so: undefined symbol: mysql_real_connect |
Une idée ?