This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sqrt problem


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.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]