0
This C code is not compiling in Atom, but in Codeblocks it is working normally.
#include <stdio.h>
#include <math.h>
int main(){
int a, b, hipotenusa, catetos;
printf("A: ");
scanf("%d", &a);
printf("B: ");
scanf("%d", &b);
catetos = (a * a) + (b * b);
hipotenusa = sqrt(catetos);
printf("Hipotenusa = %d", hipotenusa);
return 0;
}
Error:
gcc-make-run: Compile Error
/tmp/cc4PjTLW.o: in function `main':
capitulo13.c(.text+0x86): undefined reference to `sqrt'
collect2: error: ld return 1 exit status
Try using text instead of images to describe your error. The way it was, your question wouldn’t go in the search for the site even if someone had the same problem in the future. Also, screen reader users could not help you.
– Pablo Almeida
Which compiler are you using ? What build flags ? Which command did you use to compile ? The error certainly in these points I asked. Here’s how I compiled and ran the program without problem -> https://i.stack.Imgur.com/Devxy.png
– Isac
I don’t use Windows, and the gcc command on the terminal doesn’t work, the problem is that it doesn’t compile either in the terminal or in Atom when I use.
– user71383
I was able to solve the problem, I used the -lm option in the editor’s build settings.
– user71383
@Starlord Post a reply with details if you can.
– Pablo Almeida
Same solution, different function: https://answall.com/q/246122/64969 possible duplicate?
– Jefferson Quesado
The solution to my problem was to use the '-lm' argument in the build command of the program, for example: $ gcc 'program name_do_program. c' -lm -o 'script name'
– user71383