为什么我有这个错误?

时间:2013-04-04 11:38:42

标签: c++ c

我有这段代码,而且当我编译时,我有这个错误:

1>main1.obj : error LNK2019: unresolved external symbol _AsmSearchDll referenced in function _main
1>D:\Projects\C++\CascadeTrain\Debug\LicentaOpenCv2.4.4.exe : fatal error LNK1120: 1 unresolved externals


#include "stasm_dll.hpp"

int main (int argc, char** argv)
{
    const char *image_name = "D:\\Projects\\C++\\CascadeTrain\\CascadeTrain\\Images\\12\\FirstWide\\frame1.jpg";

    IplImage *img = cvLoadImage(image_name, CV_LOAD_IMAGE_COLOR);
    if (img == NULL) {
        printf("Error: Cannot open %s\n", image_name);
        return -1;
    }

    // locate the facial landmarks with stasm

    int nlandmarks;
    int landmarks[500]; // space for x,y coords of up to 250 landmarks
    AsmSearchDll(&nlandmarks, landmarks,
                 image_name, img->imageData, img->width, img->height,
                 1 , NULL , NULL );

    if (nlandmarks == 0) {
        printf("\nError: Cannot locate landmarks in %s\n", image_name);
        return -1;
    }

#if 0 // print the landmarks if you want
    printf("landmarks:\n");
    for (int i = 0; i < nlandmarks; i++)
        printf("%3d: %4d %4d\n", i, landmarks[2 * i], landmarks[2 * i + 1]);
#endif

    // draw the landmarks on the image

    int *p = landmarks;
    cvPolyLine(img, (CvPoint **)&p, &nlandmarks, 1, 1, CV_RGB(255,0,0));

    // show the image with the landmarks

    cvShowImage("stasm example", img);
    cvWaitKey(0);
    cvDestroyWindow("stasm example");
    cvReleaseImage(&img);
    return 0;
}

我在同一目录中有.cpp和.dll。

2 个答案:

答案 0 :(得分:1)

编译器找不到AsmSearchDll的定义。这可能是因为您没有链接函数的.cpp定义。

答案 1 :(得分:0)

您可能需要链接AsmSearchDll的导入库。在编译时将它放在同一目录中是不够的。但是,当你运行时,你确实需要它。