# Thread: Well-done, but can't compile

1. ## Well-done, but can't compile

Hello gentle folks
I got this code
Code:
```#include <math.h>
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
float a, b, c;
float delta;
float x1, x2;

printf("Risoluzione equazioni di secondo grado\n");
printf("Equazione nella forma ax^2+bx+c=0\n");

printf("Immetti il coefficiente a: \n");
scanf("%f", &a);
printf("Immetti il coefficiente b: \n");
scanf("%f", &b);
printf("Immetti il coefficiente c: \n");
scanf("%f", &c);
if ( a == 0 )
{
if ( b != 0 )
{
x1 = -c / b;
printf("Una soluzione:x=%f\n", x1);
}
else
{
if ( b == 0 )
{
printf("Equazione indeterminata: ammette infinite soluzioni\n");
}
else
{
printf("Equazione impossibile\n");
}
}
}
else
{
delta = b*b - (4*a*c);
printf("Il discriminante vale: %f \n", delta);
if ( delta < 0 )
{
printf("Non ci sono soluzioni in campo reale\n");
}
else if ( delta == 0 )
{
x1 = -b / (2*a) ;
printf("Una soluzione doppia: x=%f \n", x1);
}
else
{
x1 = ( -b - sqrt(delta) ) / ( 2 * a );
x2 = ( -b + sqrt(delta) ) / ( 2 * a );
printf("Due soluzioni x:%f e %f \n", x1, x2);
}
}

exit(0);
}```
No mistakes, but i can't compile due to this warnings:

Can someone help me to understand?

2. Hello Alcatraz, my guess is that you have to link against the C math library to get the implementations of the functions in the math.h header. This seems to be a quirk in C.

So simply try adding -lm (a small L) to your compiler flags and see if that fixes it.

3. I tried,same error
If I try with "compile object" it tells me compilation well done but no file .exe is generated

4. What are "%e" and "%f"?

Only add -lm at the end of Build, after "%f", and nowhere else and see if that works.

5. Also, your IDE might offer a better way for adding libraries, please read the documentation on that.

6. ->Which documentation do you mean? The IDE's one?
->"%e" and "%f" are standard, I didn't add those

7. It works now If i build btw. Thanks
If I press "compile everything" compiler tells me : "make: *** No targets specified and no makefile found. Stop."
If I press "compile object" compiler tells me: make: 'Esercizio-n11x.o' is up to date.

8. If I press "compile everything" compiler tells me : "make: *** No targets specified and no makefile found. Stop."
You might want to read your IDE documentation in case your setup uses a default makefile and target.

The way that make works is "make -f <makefile> <target>" when specifying a file and target, or "make <target>" when you have a default makefile. make automatically tries to read files with variations of the name "makefile". Here is a page with some quick instructions: ftp://ftp.gnu.org/old-gnu/Manuals/ma...er/make_9.html

If I press "compile object" compiler tells me: make: 'Esercizio-n11x.o' is up to date.
This is usually good, it means that you've made no changes since your last compile, so the compiler has nothing to do.

9. As a side note, because 'a' 'b' and 'c' are floats, you should do the following...

Code:
```if (a == 0.0)
{
...```

Popular pages Recent additions