NetBSD-Users archive

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

Re: libm trigonometric functions and i387



   Date: Wed, 25 Feb 2009 15:17:02 -0500
   From: Thor Lancelot Simon <tls%rek.tjls.com@localhost>

   On Wed, Feb 25, 2009 at 02:57:22PM -0500, Taylor R Campbell wrote:
   > 
   > Curiously, my attempts to statically link the attached file fail:
   > 
   > % gcc -c test.c -o test.o
   > % gcc -static -lm test.o -o test

   This is incorrect syntax on the compiler command line.  The order of
   objects to be linked together matters!  You are not trying to resolve
   symbols wanted by libm using test.o, after all.

Oops.  Too seldom do I invoke gcc manually to remember these details.
Statically linked against libm, I get the right answer:

% gcc -static -o test test.o -lm
% ./test 1e22
sin (1.000000e+22) = -8.522008e-01

If I statically link against libm387 instead, of course, I get the
wrong answer.  So code to compute good approximations is certainly
installed in NetBSD.  Now is there any way to get this with dynamic
linking, short of editing /etc/ld.so.conf?

(I am not subscribed to this list; please cc me in replies.)


Home | Main Index | Thread Index | Old Index