Re: sqrt problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ali, Andrew,

On Mon, Nov 17, 2014 at 10:27 AM, Andrew Haley <aph@xxxxxxxxxx> wrote:
> On 11/17/2014 06:16 PM, Ali Abdul Ghani wrote:
>> /tmp/cc0fh9Tm.o: In function `eratosthenes':
>> q.c:(.text+0x31): undefined reference to `sqrt'
>> collect2: error: ld returned 1 exit status
>> What is the problem and what is the solution?
>
> If you want math, you link with libm.
>
> http://stackoverflow.com/questions/5419366/why-do-i-have-to-explicitly-link-with-libm
> http://stackoverflow.com/questions/1033898/why-do-you-have-to-link-the-math-library-in-c
>
> This has been so since the dawn of time itself.

It also depends on the libc. For instance, libm is a part of libc for
musl-libc (although libm.so is still provided as a symlink for
compatibility), and MSVCRT/libmingwex.a:
http://mingw.5.n7.nabble.com/Problem-with-libm-a-tt3001.html#a3002

> Andrew.
>

-Bryan




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux