Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HELP NEEDED FOR C ON UNIX!!!!

Hi,

I am currently developing a program that uses a formula in which the square root of a number needs to be found.

I have tried using the square root function (sqrt), and including the header file but the comiler will still not recognise the sqrt function?

Do you know any other header files i should be including or any other method of equating the square root of a variable?

Comments

  • bilderbikkelbilderbikkel Member Posts: 754
    : Hi,
    :
    : I am currently developing a program that uses a formula in which the
    : square root of a number needs to be found.
    :
    : I have tried using the square root function (sqrt), and including
    : the header file but the comiler will still not recognise
    : the sqrt function?
    :
    : Do you know any other header files i should be including or any
    : other method of equating the square root of a variable?
    :
    It should work. Perhaps your paths are set incorrectly or perhaps you've made a typo in the line before the sqrt(). Could you post your (minimal) code?

    See ya,
    bilderbikkel
  • thawoulythawouly Member Posts: 4
    : : Hi,
    : :
    : : I am currently developing a program that uses a formula in which the
    : : square root of a number needs to be found.
    : :
    : : I have tried using the square root function (sqrt), and including
    : : the header file but the comiler will still not recognise
    : : the sqrt function?
    : :
    : : Do you know any other header files i should be including or any
    : : other method of equating the square root of a variable?
    : :
    : It should work. Perhaps your paths are set incorrectly or perhaps
    : you've made a typo in the line before the sqrt(). Could you post
    : your (minimal) code?
    :
    : See ya,
    : bilderbikkel

    Hi,

    this is the part of the code in which I implement the sqrt function:


    [italic]for(i=0; i<SAMPLES; i++)
    {
    F=j*Fc;
    array[i]=Vin/sqrt(1+((Fc/F)*(Fc/F)));
    j=j+0.2;
    }[/italic]


    The compile time error i get when i try to compile it is as follows:

    [italic]Undefined first referenced
    symbol in file
    sqrt /var/tmp//ccpMpDsy.o
    ld: fatal: Symbol referencing errors. No output written to formal2
    collect2: ld returned 1 exit status[/italic]



  • bilderbikkelbilderbikkel Member Posts: 754
    And what is the error you get from the code below?

    [code]
    #include

    int main(void)
    {
    double x = sqrt(2.0);
    return 0;
    }
    [/code]

    See ya,
    bilderbikkel
  • thawoulythawouly Member Posts: 4
    : And what is the error you get from the code below?
    :
    : [code]:
    : #include
    :
    : int main(void)
    : {
    : double x = sqrt(2.0);
    : return 0;
    : }
    : [/code]:
    :
    : See ya,
    : bilderbikkel

    Hi,

    I just tried that and the error returned the exact same compile time error message:

    [italic]example.c:14:2: warning: no newline at end of file
    Undefined first referenced
    symbol in file
    sqrt /var/tmp//ccBhGNqf.o
    ld: fatal: Symbol referencing errors. No output written to example
    collect2: ld returned 1 exit status[/italic]


  • bilderbikkelbilderbikkel Member Posts: 754
    : I just tried that and the error returned the exact same compile time
    : error message:
    :
    : [italic]example.c:14:2: warning: no newline at end of file
    : Undefined first referenced
    : symbol in file
    : sqrt /var/tmp//ccBhGNqf.o
    : ld: fatal: Symbol referencing errors. No output written to example
    : collect2: ld returned 1 exit status[/italic]

    Thanks, I know what the problem is: you library path is not set correct. It CAN find math.h, but it cannot find the definition of the function, which is in another type of file.

    Depending on your programming IDE, you must set the library paths correctly.

    Good luck,
    bilderbikkel
  • thawoulythawouly Member Posts: 4
    : : I just tried that and the error returned the exact same compile time
    : : error message:
    : :
    : : [italic]example.c:14:2: warning: no newline at end of file
    : : Undefined first referenced
    : : symbol in file
    : : sqrt /var/tmp//ccBhGNqf.o
    : : ld: fatal: Symbol referencing errors. No output written to example
    : : collect2: ld returned 1 exit status[/italic]
    :
    : Thanks, I know what the problem is: you library path is not set
    : correct. It CAN find math.h, but it cannot find the definition of
    : the function, which is in another type of file.
    :
    : Depending on your programming IDE, you must set the library paths
    : correctly.
    :
    : Good luck,
    : bilderbikkel

    Hi,
    Thanks alot for your help it wasnt the path but we were missing -lm at the end of our copmpilation command.

Sign In or Register to comment.