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 04-04-2011, 06:57 AM
Ian Malone
 
Default sinf compiler error I don't understand FIXED!!

On 3 April 2011 23:25, les <hlhowell@pacbell.net> wrote:
> On Sun, 2011-04-03 at 00:13 +0100, Ian Malone wrote:
>> On 1 April 2011 23:29, les <hlhowell@pacbell.net> wrote:

>> > Clearly sinf is recognized, and compiles and runs. *It returns 1.000 as
>> > expected for M_PI/2. *But the line that is commented out will not
>> > compile.

> The first response found the error -lm which fired up the linker with
> the module. *Apparently the compiler auto replaced sinf(M_PI/2) with a
> constant and didn't throw the linker error, where as the second one put
> in the call to the math library and threw the error. *Adding -lm loads
> the library.
>
> * * * *I was compiling as C, but thought the error might have come due to my
> miscalling gcc thus invoking the C++ compiler and missing something to
> call the correct sin function i.e. sin/sinf/sinl etc. *But I had written
> good code, just misinterpreted the error and forgot the link argument.
> I guess the C++ form as you used probably seeks to find any libraries
> required by the code, preventing linker errors. *That is probably a good
> thing.
>

An old favourite, I must have misread your post, because if I'd
thought you were compiling as C not C++ that would have been the first
thing to come to mind. libm is not linked in C unless explicitly
specified, but is always included in C++: difference in the languages.
The part where it replaces the call to sinf with a constant and masks
the error is particularly devious.

I think there have been suggestions that it's time to start having
libm linked in gcc by default as the space saving (its purpose a very
long time ago) is tiny.

--
imalone
--
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 04-04-2011, 04:20 PM
Michael Hennebry
 
Default sinf compiler error I don't understand FIXED!!

On Mon, 4 Apr 2011, Ian Malone wrote:

> I think there have been suggestions that it's time to start having
> libm linked in gcc by default as the space saving (its purpose a very
> long time ago) is tiny.

It's supposed to be zero.
That is rather part of the idea behind a library:
You don't link what you don't need.
A user that desires can replace libm with
something better for his purpose.

--
Michael hennebry@web.cs.ndsu.NoDak.edu
"Pessimist: The glass is half empty.
Optimist: The glass is half full.
Engineer: The glass is twice as big as it needs to be."
--
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 04-04-2011, 08:04 PM
Ian Malone
 
Default sinf compiler error I don't understand FIXED!!

On 4 April 2011 17:20, Michael Hennebry <hennebry@web.cs.ndsu.nodak.edu> wrote:
> On Mon, 4 Apr 2011, Ian Malone wrote:
>
>> I think there have been suggestions that it's time to start having
>> libm linked in gcc by default as the space saving (its purpose a very
>> long time ago) is tiny.
>

> That is rather part of the idea behind a library:
> You don't link what you don't need.
> A user that desires can replace libm with
> something better for his purpose.
>

Yes, but what would you suggest for 'something better' with x86_64
linux as the target which is typically dynamically linked? libm is a
bit of a historical anomaly as it supplies functions which are part of
the C standard, but not in the standard library.

--
imalone
--
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 10:26 AM.

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