FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 08-11-2010, 04:31 PM
Dj YB
 
Default weird C problem

Hello,

I have written a small program in C and I am using the math.h library using
#include<math.h>
so far everything is good.
when using the function sqrt I get the next error:

$ cc a.c
/tmp/ccTaon4H.o: In function `main':
a.c.text+0x3e): undefined reference to `sqrt'

to be sure I checked man sqrt:

SYNOPSIS

#include <math.h>

double sqrt(double x);

I have no idea what is wrong, any suggestions are welcome.

Thanks,
YB.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 08-11-2010, 04:39 PM
Ralf Corsepius
 
Default weird C problem

On 08/11/2010 06:31 PM, Dj YB wrote:
> Hello,
>
> I have written a small program in C and I am using the math.h library using
> #include<math.h>
> so far everything is good.
> when using the function sqrt I get the next error:
>
> $ cc a.c
> /tmp/ccTaon4H.o: In function `main':
> a.c.text+0x3e): undefined reference to `sqrt'
>
> to be sure I checked man sqrt:
>
> SYNOPSIS
>
> #include<math.h>
>
> double sqrt(double x);

A couple of lines later you will find this sentence:
" Link with -lm."

> I have no idea what is wrong, any suggestions are welcome.
Math functions are not contained in libc, they are in a separate library
called libm.

=> cc a.c -lm

Ralf
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 08-11-2010, 05:18 PM
Dj YB
 
Default weird C problem

On Wednesday August 11 2010 19:39:55 Ralf Corsepius wrote:
> On 08/11/2010 06:31 PM, Dj YB wrote:

> > $ cc a.c
> > /tmp/ccTaon4H.o: In function `main':
> > a.c.text+0x3e): undefined reference to `sqrt'
> >
> > to be sure I checked man sqrt:
> >
> > SYNOPSIS
> >
> > #include<math.h>
> >
> > double sqrt(double x);
>
> A couple of lines later you will find this sentence:
> " Link with -lm."
>
> Math functions are not contained in libc, they are in a separate library
> called libm.
>
> => cc a.c -lm
>
> Ralf

Thanks Ralf!
I knew there must be something really basic I am missing.

Regards,
YB.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 

Thread Tools




All times are GMT. The time now is 09:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org