still square root

This is a discussion on still square root within the C Programming forums, part of the General Programming Boards category; The code: (by Govtcheez) #include <math.h> #include<stdio.h> int main(void) { int x = 4; int y = sqrt(x); printf("%d",y); return ...

  1. #1
    help
    Guest

    Unhappy still square root

    The code:
    (by Govtcheez)

    #include <math.h>
    #include<stdio.h>
    int main(void)
    {
    int x = 4;
    int y = sqrt(x);
    printf("%d",y);
    return 0;
    }

    Don't work.

    It comes up with:

    gcc -I/u1/pg/aramis/Lib/PI2/include -w -O2 -Dsolaris7 -Dsparc ./src/sq.c -L/u1/pg/aramis/Lib/PI2/lib/sparc-solaris7 -lPI2 -o ./bin/sq
    Undefined first referenced
    symbol in file
    sqrt /var/tmp/cc6vnBFb.o
    ld: fatal: Symbol referencing errors. No output written to ./bin/sq
    collect2: ld returned 1 exit status
    *** Error code 1
    make: Fatal error: Command failed for target `conv'

    What's up?

  2. #2
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Compile with -lm

  3. #3
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    -lm

    This enables the math functions. If you get into the habbit of always compiling with -lm than it won't hurt.
    I compile code with:
    Visual Studio.NET beta2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program to calculate the square root
    By saszew in forum C Programming
    Replies: 7
    Last Post: 10-28-2008, 01:53 PM
  2. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 07:57 PM
  3. Bisection Method function value at root incorrect
    By mr_glass in forum C Programming
    Replies: 3
    Last Post: 11-10-2005, 09:10 AM
  4. Square Root ?!?
    By Tm687 in forum C++ Programming
    Replies: 1
    Last Post: 02-29-2004, 04:38 PM
  5. Templated Binary Tree... dear god...
    By Nakeerb in forum C++ Programming
    Replies: 15
    Last Post: 01-17-2003, 02:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21