0

I am having difficulties while trying to link a file to my main code in order to interpolate a polynomial I have written minimal code and I have all the files used in the interpolation under the same directory. The files are from the book Numerical Recipes. I have minimal experience in linking external libraries and using subroutines in C. I would be glad if you can provide some assistance. The code and the associated files are as follows: nrutil.c ; nrutil.h; POLINT.C

#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <POLINT.C>
int main()
{
    int i;
    long double x[11], erf[11];
    for(i = 0; i <11; i++)
    {
        x[i] = i / 10.0;
        erf[i] = erfl(x[i]);
        printf("x is %Lf \n", x[i]);
    }


    return 0;
}
Vesnog
  • 773
  • 2
  • 16
  • 33

1 Answers1

1

Try:

Do not include POLINT.C

If you really have to compile everything all at once:

gcc POLINT.C nrutil.c -o nrutil -lm
jim mcnamara
  • 16,005
  • 2
  • 34
  • 51
  • Thanks I think that sort of worked out actually I copied and pasted part of the code to my main file and put an header as nrutil.h inside it and compiled it along with nrutil.c – Vesnog Nov 29 '13 at 19:25