Thread: still square root

  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, 12:53 PM
  2. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 06: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