Re: sinf compiler error I don't understand (corrected)

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

 



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\n",M_PI);
>>     printf ("sin 90 = %e\n",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\n",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@xxxxxxxxxxxxxxxxxxxxx
"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@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux