CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: error LNK2001: unresolved external symbol

  1. #1
    Join Date
    Feb 2010
    Posts
    23

    error LNK2001: unresolved external symbol

    I am struggling with this error since morning and I don't know why it is occurring. When I was not using the vector.pushback function and making a simpler program this error was not occuring? Here is the code of the function below.

    error LNK2001: unresolved external symbol "int __cdecl findSource(int,float *,int)" (?findSource@@YAHHPAMH@Z)
    Debug/test_geodesic.exe : fatal error LNK1120: 1 unresolved externals

    The function is written here:

    int findSource(int p, float* geodesic, int xsize,vector<int> &minimalPath){
    // Neighbors of Final Point
    const int neighborCount= 4;
    // Current value of backpropagating pixel
    int current=p;

    //Variable storing current distance from source point
    float dist= geodesic[current];

    //Continue propagating till source point is identified

    while ( dist>0.0f){

    //Array of neighbor locations
    int neighbors[neighborCount]= {(current+X), (current-X), (current+Y), (current-Y)};

    //Array of geodesic distance of + X,-X,+Y and -Y neighbors
    float distneighbors[neighborCount]={geodesic[current+X],geodesic[current-X],geodesic[current+Y],geodesic[current-Y]};

    //finding minimum of neighbors
    for (int i=0;i<neighborCount;i++){
    if (distneighbors[i]< dist) { cout<<dist<<endl;

    dist=distneighbors[i]; current=neighbors[i]; minimalPath.push_back(neighbors[i]);
    }
    }
    }
    return current;
    }


    The following function below calls the above function:

    int signedDistanceTransform2D(float *in,float *out,float *euc_out,int xsize,int ysize,float *phi,int &heapSize,long *boundaryPoints, int &source, vector<int> &minimalPath) {
    int p,q; //Index of current point and neighbor
    int i,j; //2D offsets of current point
    int gridsize=xsize*ysize; //Total size of grid
    float xnhbr,ynhbr,euc_xnhbr,euc_ynhbr,out_x,out_y; //Values of upwind neighbors
    float t1,t2; //Value of linear interpolation weight
    float sum,diff,discriminant; //Used in solving quadratic
    int nbhd; //Neighborhood bits
    int num_iter=0; //count of number of iterations
    const int max_iter=80000; // number of iterations wanted
    const float lambda=30.000f; //Euclidean length interval for cheacking gradient

    int *status=new int[gridsize]; //Status (NEW/ACTIVE/DONE) of grid points
    int *bckptr=new int[gridsize]; //Backpointers to grid points within heap

    minimalPath.clear();

    //reserve space for minimal path
    minimalPath.reserve(gridsize/100);

    minheap pheap(out,bckptr,gridsize); //Heap for boundary points

    enum {XPOS=1,XNEG=2,XNHBR=3, YPOS=4,YNEG=8,YNHBR=12};
    enum {NEW=0, ACTIVE=1, DONE=2};

    //Initialize status and distance functions both euclidean and geodesic

    memset(status,NEW,gridsize*sizeof(int));

    for (p=0; p<gridsize; p++) out[p]= in[p];
    for (p=0; p<gridsize; p++) euc_out[p]= in[p];
    cout << "Test" << std::endl;



    //Initialize heaps
    for (p=0; p<gridsize; p++)
    if(out[p]==0){
    if (status[p]==NEW) {pheap.push(p); status[p]=DONE;}
    }



    cout << "Test1" << std::endl;
    cout << "Test2" << std::endl;
    //Perform fast marching procedure for points

    while (pheap.pop(p)) {

    status[p]=DONE;
    j=p/xsize; i=p-j*xsize;




    //Update -X neighbor

    if (i>0 && status[q=p-X]!=DONE) {
    ITERATE_OUTWARD(i-1,j,q,phi[q]);
    if (status[q]==NEW) {status[q]=ACTIVE; pheap.push(q);}
    else {pheap.upheap(bckptr[q]); pheap.downheap(bckptr[q]);}
    }

    //Update +X neighbor

    if (i<xsize-1 && status[q=p+X]!=DONE) {
    ITERATE_OUTWARD(i+1,j,q,phi[q]);
    if (status[q]==NEW) {status[q]=ACTIVE; pheap.push(q);}
    else {pheap.upheap(bckptr[q]); pheap.downheap(bckptr[q]);}
    }

    //Update -Y neighbor

    if (j>0 && status[q=p-Y]!=DONE) {
    ITERATE_OUTWARD(i,j-1,q,phi[q]);
    if (status[q]==NEW) {status[q]=ACTIVE; pheap.push(q);}
    else {pheap.upheap(bckptr[q]); pheap.downheap(bckptr[q]);}
    }

    //Update +Y neighbor

    if (j<ysize-1 && status[q=p+Y]!=DONE) {
    ITERATE_OUTWARD(i,j+1,q,phi[q]);
    if (status[q]==NEW) {status[q]=ACTIVE; pheap.push(q);}
    else {pheap.upheap(bckptr[q]); pheap.downheap(bckptr[q]);}
    }

    //Break when a euclidean length greater than lambda is crossed
    if (euc_out[p]>=lambda){

    //find sourcepoint from which it came
    int source= findSource(p,out,xsize);

    //identify boundarypoints
    pheap.getBoundaryPoints(boundaryPoints,heapSize);

    break;
    }
    }
    delete[] status; delete[] bckptr;
    return p;

    }

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,588

    Re: error LNK2001: unresolved external symbol

    int source= findSource(p,out,xsize);

    You didn't provide the implementation for that function.

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: error LNK2001: unresolved external symbol

    Quote Originally Posted by vkaul1 View Post
    Here is the code of the function below.

    error LNK2001: unresolved external symbol "int __cdecl findSource(int,float *,int)" (?findSource@@YAHHPAMH@Z)
    Debug/test_geodesic.exe : fatal error LNK1120: 1 unresolved externals

    The function is written here:

    int findSource(int p, float* geodesic, int xsize,vector<int> &minimalPath){
    That's the problem -- you thought that the function is the one the linker is complaining about. It isn't.
    Code:
    int findSource(int,float *,int)  // linker can't find this function
    //...
    int findSource(int p, float* geodesic, int xsize,vector<int> &minimalPath) // here is the function you wrote
    Those are not the same function. One takes 3 parameters, the other takes 4 parameters.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)