I am getting an error stating pythagorean.so: undefined symbol: cos
. I am compiling with the math.h
, stdlib.h
, and stdio.h
libraries and the -lm
switch. Here a code snippet:
static bool
law_of_cosine_run(esh_command* cmd)
{
if (strcmp(cmd->argv[0], "lawofcosine") == 0) {
printf("The length of the third side is: %f\n",
law_of_cosine(strtol(cmd->argv[1], NULL, 10),
strtol(cmd->argv[2], NULL, 10), strtol(cmd->argv[3], NULL, 10)));
return true;
}
return false;
}
static double
law_of_cosine(double x, double y, double z)
{
return sqrt((x * x) + (y * y) - (2 * x * y * cos(z)));
}
Does anyone know why this would occur? pythagorean.c is my .c file.
Thanks
编译时,请确保您键入
gcc *.c -lm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.