Bonjour à tous,
Je suis très débutant au niveau programmation et j'ai un gros problème: impossible de compiler mon application en C. j'utilise kDevelop 3.5.1 avec gcc 4.2.3 sous Debian.
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NFOIS 5
 
int main(int argc, char *argv[])
{
    /* Initialisation des variables */
    int i;
    float x , racx;
 
    /* Le logiciel est poli: il dit bonjour ;) */
    printf ("Bonjour\n");
    printf ("Je vais vous calculer %d racines carrées\n", NFOIS);
 
    for (i=0; i<NFOIS;i++)
    {
        /* Demande à l'utilisateur les données */
 
        printf ("Donnez un chiffre :");
        scanf ("%f", &x);
    if (x < 0.0)
        printf ("Le nombre %f ne possède pas de racines carrée\n", x);
    else {
        racx = sqrt (x);
        printf ("Le nombre %f a pour racine carrée : %f\n", x, racx) ; }}
    printf ("Travail terminé - Salut");
    return 0;
}
Comme précisé sur un autre article du forum, j'ai compilé avec gcc en ajoutant l'argument -lm mais rien n'y fait. la sortie me dit toujours :
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
cd '/home/simon/Dev/HelloMain/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" LC_MESSAGES="C" LC_CTYPE="C" make -k 
make all-recursive
Making all in src
cd /home/simon/Dev/HelloMain && /bin/bash /home/simon/Dev/HelloMain/missing --run automake-1.10 --gnu src/Makefile
cd .. && /bin/bash ./config.status src/Makefile depfiles
config.status: creating src/Makefile
config.status: executing depfiles commands
linking hellomain (gcc)
hellomain.o: In function `main':
/home/simon/Dev/HelloMain/src/hellomain.c:30: undefined reference to `sqrt'
collect2: ld returned 1 exit status
make[2]: *** [hellomain] Error 1
make[2]: Target `all' not remade because of errors.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
*** Exited with status: 2 ***
Le fichier math.h existe bien, j'ai vérifié. Que faut-il faire ?
Merci d'avance
Simon