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-01-2011, 10:46 PM
les
 
Default sinf compiler error I don't understand (corrected)

On Fri, 2011-04-01 at 15:29 -0700, les wrote:
> First let me say, that while I have used C++ I don't normally use it for
> my work and so am not throughly familiar with what it does, so if this
> is due to a C++ error, please be gentle.
>
> I am working on some DSP code I developed a long time ago, and now want
> to port it to 64 bit. I have read several articles on the differences
> in C and C++ between 32 and 64 bit, but this has me stymied.
>
> Here is the smallest sample I have been working with to show the current
> error:
>
> #include <math.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
>
> main()
> {
> long double temp;
> printf ("M_PI=%e
",M_PI);
> printf ("sin 90 = %e
",sinf(M_PI/2));
> temp=M_PI/2.0;
> // the following line won't compile for temp
> // regardless of how temp is declared (float, double, long double)
> // printf ("sin 90 = %e
",sinf(temp));
> }
>
>
> 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.
>
> If you can see the issue here, please let me know.
>
> MY system is:
> Release Kernel Linux 2.6.35.11-83.fc14.x86_64 ****** fixed *****
> GNOME 2.32.0
> Hardware
> Memory 7.8GiB
> AMD Phenom(tm) II X6 1035T
> Lots of disk space
>
> yum info GCC shows:
> Name : gcc
> Arch : x86_64
> Version : 4.5.1
> Release : 4.fc14

missing command and error message:
gcc -ggdb mathck.c
/tmp/ccTdnf1Z.o: In function `main':
/home/lesh/Code/C/arb_wav_file/mathck.c:14: undefined reference to
`sinf'
collect2: ld returned 1 exit status


>
> Thanks,
> Les H
>



--
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-01-2011, 10:55 PM
Michael Hennebry
 
Default sinf compiler error I don't understand (corrected)

On Fri, 1 Apr 2011, les wrote:

> On Fri, 2011-04-01 at 15:29 -0700, les wrote:

>> Here is the smallest sample I have been working with to show the current
>> error:
>>
>> #include <math.h>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <string.h>
>>
>> main()
>> {
>> long double temp;
>> printf ("M_PI=%e
",M_PI);
>> printf ("sin 90 = %e
",sinf(M_PI/2));
>> temp=M_PI/2.0;
>> // the following line won't compile for temp
>> // regardless of how temp is declared (float, double, long double)
>> // printf ("sin 90 = %e
",sinf(temp));
>> }
>>
>>
>> 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.
>>
>> If you can see the issue here, please let me know.


> missing command and error message:
> gcc -ggdb mathck.c
> /tmp/ccTdnf1Z.o: In function `main':
> /home/lesh/Code/C/arb_wav_file/mathck.c:14: undefined reference to
> `sinf'
> collect2: ld returned 1 exit status

Aha!
It did compile.
It just didn't link.
You are missing -lm .
In the first use,
perhaps the compiler recognized sinf(M_PI/2)
and replaced it with a constant.
In that case, no reference would be made.

--
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
 

Thread Tools




All times are GMT. The time now is 12:16 AM.

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