Hi,
when i try to compile this code:
#include <math.h>
int main (void) {
double x, y;
x = 2;
y = sqrt(x);
return 0;
}
With the command:
$ gcc test.c
I got this message:
/tmp/cc5QZmCN.o: In function 'main':
test.c:(.text+0x16): undefined reference to 'sqrt'
collect2: error: ld returned 1 exit status
Any help?
I tried this on a fresh jessie install.
I have the same problem on wheezy.
Thanks in advance.
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
[SOLVED]noob: can't access math function
[SOLVED]noob: can't access math function
Last edited by arca on 2015-05-01 10:44, edited 1 time in total.
Re: noob: can't access math function
There's lots of stuff on this.
Here's one http://linux.die.net/man/3/sqrt
I do think you will want build-essential installed.
Here's one http://linux.die.net/man/3/sqrt
Code: Select all
gcc -o test test.c -lm
Jessie/Xfce
Re: noob: can't access math function
It works with the -lm option! Great.
Thank you very much, it was really frustrating.
Thank you very much, it was really frustrating.