Results 1 to 3 of 3

Thread: simple sqrt function doesn't work!

  1. #1

    Thread Starter
    Fanatic Member sbasak's Avatar
    Join Date
    Aug 2001
    Location
    Globe Trotter
    Posts
    524

    simple sqrt function doesn't work!

    the following very basic code is not compiling in Dynix.
    It says undefind symbol sqrt first referenced in file souce.o

    /* file source.c */
    #include<stdio.h>
    #include<math.h>

    void main(void)
    {
    double i;
    i=sqrt(25.00);
    printf("value is = %i\n",i);
    }
    /* end of code*/

    Where is the problem? Why sqrt doesn't work even if I included math.h?
    Life is a one way journey, not a destination. Travel it with a smile and never regret anything.
    Yesterday is history, tomorrow is a mystery, today is gift - that's why we call it present.

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    I don't know dynix - but - most unix command line compilers require that you tell them to link in the mathlib something like this

    cc -lm myfile.c

    try: man cc


    for specific information for your compiler on how to link the math library.

  3. #3
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Also - most man pages have the information you need by typing:

    man math

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width