🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

13 total messages Started by Iouri Sorkine Thu, 01 Feb 1996 07:28
Problem with C for the mathematical programm
#2
Author: Iouri Sorkine
Date: Thu, 01 Feb 1996 07:28
8 lines
664 bytes
I execute "cc name.c" and receive "ld: Undefined symbol
                                       _cos
                                       _sin
and so on...                                ". 
What's wrong?        

Yuri Sorkin
Re: Problem with C for the mathematical programm
#4
Author: Chris Trueman
Date: Thu, 01 Feb 1996 08:32
17 lines
1293 bytes
In article <4epq2e$h4b@crl2.crl.com> sorkin@crl.com "Iouri Sorkine" writes:

>
>I execute "cc name.c" and receive "ld: Undefined symbol
>                                       _cos
>                                       _sin

Try linking the math library with: cc name.c -lm

			- Chris

-============================================================================-
IntelliCorp Applications Consultant / E-mail: truemanc@intellic.demon.co.uk
LiveModel and PowerModel are part   / CServe: 100255,701
of IntelliCorp's MODELWORKS	    / Tel   : +44 (0)1344 305305
application development suite.      / Fax   : +44 (0)1344 305100
-============================================================================-
Re: Problem with C for the mathematical programm
#3
Author: Shaun Flisakowski
Date: Thu, 01 Feb 1996 09:00
18 lines
979 bytes
In article <4epq2e$h4b@crl2.crl.com>, Iouri Sorkine <sorkin@crl.com> wrote:
>
>I execute "cc name.c" and receive "ld: Undefined symbol
>                                       _cos
>                                       _sin
>and so on...                                ". 
>What's wrong?        

    You didn't link in the math library, try something like:

    cc -c name.c
    cc -o name name.o -lm

-- 
    Shaun        flisakow@cs.wisc.edu

   "In your heart you know its flat."
                           -Flat Earth Society
Re: Problem with C for the mathematical programm
#5
Author: Andreas John
Date: Thu, 01 Feb 1996 09:05
4 lines
695 bytes
You have to tell the linker to use the mathematical library:
cc name.c -lm

A. John
Re: Problem with C for the mathematical programm
#6
Author: Richard Czech
Date: Thu, 01 Feb 1996 13:46
22 lines
1388 bytes
In article <4epq2e$h4b@crl2.crl.com>, sorkin@crl.com (Iouri Sorkine) writes:
|> 
|> I execute "cc name.c" and receive "ld: Undefined symbol
|>                                        _cos
|>                                        _sin
|> and so on...                                ". 
|> What's wrong?        

You didn't read the manual page. Try "man cos" and you'll find

  SYNOPSIS
     cc [ flag ... ] file ...  -lm [ library ... ]

Then you may execute "cc name.c -lm".


----------------------------------------------------------------------
       Richard Czech                      e-mail: Richard.Czech@gmd.de
	 GMD-SET
   Schloss Birlinghoven                   phone:    (+49) 2241 14 2039
53754 St. Augustin, Germany               fax:      (+49) 2241 14 2342
----------------------------------------------------------------------
Re: Problem with C for the mathematical programm
#7
Author: Gordon Royle
Date: Thu, 01 Feb 1996 14:52
25 lines
882 bytes
sorkin@crl.com (Iouri Sorkine) writes:


>I execute "cc name.c" and receive "ld: Undefined symbol
>                                       _cos
>                                       _sin

Need to include the math libraries.

Put

#include <math.h>

in your program

and compile with

cc name.c -lm


gordon
-- 
Gordon Royle ---- gordon@cs.uwa.edu.au
Visit http://www.cs.uwa.edu.au/~gordon
--
Re: Problem with C for the mathematical programm
#8
Author: Ross Wilson
Date: Thu, 01 Feb 1996 23:41
24 lines
1038 bytes
sorkin@crl.com (Iouri Sorkine) wrote:


>I execute "cc name.c" and receive "ld: Undefined symbol
>                                       _cos
>                                       _sin
>and so on...                                ". 
>What's wrong?        

You will need to include the math library.  How you do this depends on
what operating system and/or compiler you are using.

If you use UNIX, do:

	cc -lm name.c

If you use Borland, Microsoft, whatever, you will have to read the
manual.

Don't forget to #include <math.h>.

Hope this helps,

Ross
Re: Problem with C for the mathematical programm
#10
Author: P.Bennett
Date: Fri, 02 Feb 1996 05:59
35 lines
1865 bytes
In article <4erfj5$f5c@canb.cin.gov.au>, rossw@cin.gov.au (Ross Wilson) writes...
>sorkin@crl.com (Iouri Sorkine) wrote:

>>I execute "cc name.c" and receive "ld: Undefined symbol
>>                                       _cos
>>                                       _sin
>>and so on...                                ". 
>>What's wrong?        

>You will need to include the math library.  How you do this depends on
>what operating system and/or compiler you are using.

>If you use UNIX, do:
> 
>	cc -lm name.c

Although I don't do unix, I've seen this often enough to know that libraries
_must_ be listed at the _end_ of the command line:
	cc name.c -lm
> 
>If you use Borland, Microsoft, whatever, you will have to read the
>manual.

Borland and Microsoft very nicely put the math functions in the main library,
so you don't have to worry about this nonsense - MS-DOS _does_ have some
advantages  :-)

>Don't forget to #include <math.h>.


Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
Internet: bennett@triumf.ca         | of one another only when one can be
Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
Re: Problem with C for the mathematical programm
#9
Author: Eric Penn
Date: Fri, 02 Feb 1996 09:16
14 lines
1372 bytes
P.Bennett (bennett@erich.triumf.ca) wrote:

 >Borland and Microsoft very nicely put the math functions in the main library,
 >so you don't have to worry about this nonsense - MS-DOS _does_ have some
 >advantages  :-)

Wow!  Sure is nice to know that you can get bloated object modules with all sorts of unneeded math calls included - by 
default!  Sure hope they have a really spiffy linker and global optimizer to weed out all that extra code....

-- 
   Eric Penn                                STUPID's three rules to life:
  stupid@crl.com                             Stick with what you're good at,
 http://www.crl.com/~stupid/                  Learn from your mistakes, and
"stoo"                                         When in doubt, act stupid!
Re: Problem with C for the mathematical programm
#11
Author: WOOD JAMEY RYAN
Date: Sat, 03 Feb 1996 03:55
10 lines
811 bytes
In article <4epq2e$h4b@crl2.crl.com>, Iouri Sorkine <sorkin@crl.com> wrote:
>
>I execute "cc name.c" and receive "ld: Undefined symbol
>                                       _cos
>                                       _sin

To use these functions you need to tell the compiler to link with the math 
libraries.  To do this, try: "cc name.c -lm"

--Jamey
Re: Problem with C for the mathematical programm
#12
Author: Scott G. Hall
Date: Sat, 03 Feb 1996 15:10
34 lines
2173 bytes
Eric Penn <stupid@crl.com> wrote:
>P.Bennett (bennett@erich.triumf.ca) wrote:
> >Borland and Microsoft very nicely put the math functions in the main library,
> >so you don't have to worry about this nonsense - MS-DOS _does_ have some
> >advantages  :-)
>
>Wow!  Sure is nice to know that you can get bloated object modules with all
>sorts of unneeded math calls included - by default!  Sure hope they have a
>really spiffy linker and global optimizer to weed out all that extra code....

I see you have done little or no DOS-based development.  For about 15 years
now, most DOS-based linkers only include objects from the library that are
referenced in the program.  Second, most of the latest crop of linkers for
windows reference dynamic libraries where the object code is not included
in the executable at all.  You don't get bloated programs, but rather trim
ones.

Also please note, several of the latest UNIXes are also using the same
idea in the linker -- include only those statically linked objects that
are referenced by the code.  These same linkers have configuration files
that can set the list of libraries to search by default, so now you can
automatically have the math library, curses & termlibs, and so on
included without specifying them on the command line, and since only
objects referenced are included, not worry about bloated programs.





-- 
- sgh	  What are you doing, reading the words at the bottom?!?   Key Grip!?!
	  What is a key grip anyway?!  I don't give credit to anybody -- it's
Scott G. Hall     (Scott.Hall@att.com)			all my show!!  - Duckman
AT&T Bell Laboratories - GCBS, Columbus, OH, USA
Re: Problem with C for the mathematical programm
#13
Author: Lawrence Kirby
Date: Tue, 06 Feb 1996 13:52
15 lines
1229 bytes
In article <4evtse$o4u@nntpa.cb.att.com>
           sgh@cbgbcs.cb.att.com "Scott G. Hall" writes:

>Also please note, several of the latest UNIXes are also using the same
>idea in the linker -- include only those statically linked objects that
>are referenced by the code.

Unix linkers have been doing this for years. Maybe you're getting
confused with dynamic linking.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Re: Problem with C for the mathematical programm
#14
Author: Guus Leeuw jr.
Date: Tue, 06 Feb 1996 16:31
23 lines
1340 bytes
sorkin@crl.com (Iouri Sorkine) wrote:
>
>I execute "cc name.c" and receive "ld: Undefined symbol
>                                       _cos
>                                       _sin
>and so on...                                ". 
>What's wrong?        
>
>Yuri Sorkin
>

Well, you forgot to link your math library.

You should be using `cc name.c -lm' if an executable image is that what you
want. If not, you should be using `cc -c name.c'.

The `-lxx' tells cc to tell the ld command to link `xx' to the executable image
aswell. The `-c' option tells cc to compile only (ie don't generate an
executable image).

Hope this helps,
	Guus Leeuw jr.
	guusl@eiffel.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads