-4

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

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 。

4

2 回答 2

1

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

于 2013-04-04T11:40:52.887 回答
0

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

于 2013-04-04T12:01:20.673 回答