unresolved externals when execute the programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yuan
    New Member
    • Mar 2008
    • 1

    unresolved externals when execute the programming

    halo.. i face problem when i execute the programming.

    it appear the error as :
    1.obj : error LNK2001: unresolved external symbol "double __cdecl NR::trapzd(doub le (__cdecl*)(doub le),double,doub le,int)" (?trapzd@NR@@YA NP6ANN@ZNNH@Z)
    Debug/1.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    can anyone help me ? thanks in advance .

    below is the programming :

    #include <iostream>
    #include<iomani p>
    #include<cmath>
    # include<math.h>
    #include<fstrea m>
    #include "nr.h"
    # include<stdio.h >
    # include <stdio.h>
    /*ifndef _NR_UTIL_H_
    #define _NR_UTIL_H_
    #include <string>
    #include <cmath>
    #include <complex>
    #include<fstrea m>
    #include <iostream>*/
    using namespace std;

    // Driver for routine trapzd
    DP func(const DP x)
    { return (x*x)*(x*x-2.0)*sin(x);
    }

    DP fint(const DP x)
    { return 4.0*x*(x*x-7.0)*sin(x)-(pow(x,4.0)-14.0*(x*x)+28.0 )*cos(x);
    }

    DP trapzd(DP func(const DP), const DP a, const DP b, const int n)
    { DP x,tnm,sum,del;
    static DP s;
    int it,j;

    if(n==1)
    { return s=0.5*(b-a)*(func(a)+fun c(b));
    }
    else {
    for(it=1,j=1;j< n-1;j++)

    tnm=it;
    del=(b-a)/tnm;
    x=a+0.5*del;
    for(sum=0.0,j=0 ;j<it;j++,x+=de l)

    s=0.5*(s+(b-a)*sum/tnm);
    return s;
    }
    }
    int main (void)
    { const int NMAX=14;
    const DP PI02=1.57079632 6794896619;
    int i;
    DP a=0.0, b=PI02,s;

    cout<<" Integral the function with 2^(n-1) points" <<endl;
    cout<<" Actual value of intgral is"<< setw(10)<<(fint (b)-fint(a))<<endl;
    cout<<setw(6)<< "n"<< setw(24)<<"appr oximate integral"<<endl ;
    cout<< fixed << setprecision(6) ;
    for(i=0;i<NMAX; i++)
    { s=NR::trapzd(fu nc,a,b,i);

    cout<<setw(6)<< (i+1)<<setw(20) <<s<<endl;
    }
    return 0;
    }
  • DaemonCoder
    New Member
    • Mar 2008
    • 43

    #2
    Check the differences between the declaration and the two calls.
    Code:
     
     
    DP trapzd(DP func(const DP), const DP a, const DP b, const int n)
     
     
    s=NR::trapzd(func,a,b,i);
     
    s=NR::trapzd(func(const DP),a,b,i);
    The top one is coming back undefined because the linker is expecting a value to be passed to the function.

    --

    The one and only.... -- Uh, What am I again?

    Comment

    Working...