[net.unix] System V C Math Routines

zsr@psuvm.bitnet.UUCP (10/20/86)

     Has anyone out there had any trouble using the Math library from AT&T
C language on a 3B(5)?  I #include math.h and the linker complains (as it
should) when I cc.  Then I compile without linking and link separatly while
including the library libm.a (-lm) and it still complains.  My program is a
simple test that uses the sin() and cos() functions, but these are always
said to be undefined by the linker.  I even tried to link the library's
filename explicitly, copied it into a file called math.o and linked that
explicitly (all the while making sure to link the C library).  No luck.
How is one supposed to use the math routines from C?  I know that I'm
labeling myself as a novice, but darn it I can't get anything to work.

     Many thanks to any kind soul who can help me out.  Please could you
respond on the net (in this news group) because direct might not work (PSU
has a funny setup...).  Again, thanks in advance.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Chris Johnson
ZSR @ PSUVMB, PSUVMA, PSUVM
^^^^^^^^^^^^

djmolny@cuae2.UUCP (10/22/86)

>     Has anyone out there had any trouble using the Math library from AT&T
>C language on a 3B(5)?  I #include math.h and the linker complains (as it
>should) when I cc.  Then I compile without linking and link separatly while
>including the library libm.a (-lm) and it still complains.  My program is a
>simple test that uses the sin() and cos() functions, but these are always
>said to be undefined by the linker.  I even tried to link the library's
>filename explicitly, copied it into a file called math.o and linked that
>explicitly (all the while making sure to link the C library).  No luck.
>How is one supposed to use the math routines from C?  I know that I'm
>labeling myself as a novice, but darn it I can't get anything to work.
>

...

The math library definitely works correctly on the 3B5.  Be sure the
-lm option is the last thing on the command line when you link, and
be sure to use the -f option as well.  An example:

	cc -f -o simple simple.c -lm

If you can't get this to work, send me a copy of your source file
and the *exact* error messages you get, and I will take a look at it.




-- 
						Regards,
						DJ Molny
						N9609U
						ihnp4!cuae2!djmolny

jjr@ut-ngp.UUCP (Jeff Rodriguez) (10/22/86)

In article <7968ZSR@PSUVMB> zsr@psuvm.bitnet.UUCP writes:
>
>     Has anyone out there had any trouble using the Math library from AT&T
>C language on a 3B(5)?  I #include math.h and the linker complains (as it
>should) when I cc.  Then I compile without linking and link separatly while
>including the library libm.a (-lm) and it still complains.
>
>Chris Johnson
>ZSR @ PSUVMB, PSUVMA, PSUVM

I once had the same problem.  My mistake was typing
	cc -lm myprog.c
instead of
	cc myprog.c -lm
The linker searches forward in the command line to find 
external references, so make sure you use the second form.

				Jeff Rodriguez
				jjr@ngp.utexas.edu