Bonjour ,
j'utilise le code suivant pour me connecter à une BD
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include </tmp/include/mysql.h> 
#include <string.h>
#define MY_SERVER_HOST "localhost"
#define MY_SERVER_PORT 0
#define MY_ACCOUNT "login"
#define MY_PASS "password"
#define MY_DB_NAME "test"
#define MY_TABLE_NAME "test_tbl"
#define MY_UX_SOCK NULL
#define MY_CLIENT_FLAG 0
 
int main(){
   MYSQL *mysql;
   MYSQL_RES *res;
   MYSQL_ROW row;
   char *query;
   unsigned int t, f;
 
   mysql=mysql_init(NULL);
   if (!mysql_real_connect(mysql,MY_SERVER_HOST,MY_ACCOUNT,MY_PASS,
        MY_DB_NAME,MY_SERVER_PORT,MY_UX_SOCK,MY_CLIENT_FLAG)) {
       printf( "Erreur de connexion : %s\n",mysql_error(mysql));
   } else {
      printf("Connexion etablie...\n");
 
      sprintf(query,"select * from %s\n", MY_TABLE_NAME);
      printf("Requete : %s", query);
 
      t=mysql_real_query(mysql, query, (unsigned int) strlen(query));
      if (t) {
         printf("Erreur dans la requete : %s\n", mysql_error(mysql));
      } else {
         if((res=mysql_use_result(mysql))) {
            printf("Resultat de la requete :\n");
            f=mysql_num_fields(res);
            while((row=mysql_fetch_row(res))) {
              for(t=0;t<f;t++) {
                printf("\t%s",row[t]);
              }
              printf("\n");
            }
               mysql_free_result(res);
         }
         else {
           printf("Erreur de recuperation du resultat : %s\n", mysql_error(mysql));
         }
      }
   }
   mysql_close(mysql);
   exit(EXIT_SUCCESS);
}
il me donne l'erreur suivante

/tmp/ccbP1cDh.o(.text+0x23): In function `main':
projet.c: undefined reference to `mysql_init'
/tmp/ccbP1cDh.o(.text+0x4b):projet.c: undefined reference to `mysql_real_connect'
/tmp/ccbP1cDh.o(.text+0x5d):projet.c: undefined reference to `mysql_error'
/tmp/ccbP1cDh.o(.text+0xd8):projet.c: undefined reference to `mysql_real_query'
/tmp/ccbP1cDh.o(.text+0xef):projet.c: undefined reference to `mysql_error'
/tmp/ccbP1cDh.o(.text+0x113):projet.c: undefined reference to `mysql_use_result'
/tmp/ccbP1cDh.o(.text+0x13e):projet.c: undefined reference to `mysql_num_fields'
/tmp/ccbP1cDh.o(.text+0x190):projet.c: undefined reference to `mysql_fetch_row'
/tmp/ccbP1cDh.o(.text+0x1a7):projet.c: undefined reference to `mysql_free_result'
/tmp/ccbP1cDh.o(.text+0x1b7):projet.c: undefined reference to `mysql_error'
/tmp/ccbP1cDh.o(.text+0x1d6):projet.c: undefined reference to `mysql_close'
collect2: ld a retourné 1 code d'état d'exécution

est ce que c'est a cause du fichier mysql.h ,par ce que je l'est recupere aprés l'extraction d'un fichier d'installation de MySql vu que je l'avais pas sur la machine .
merci