Linker error using openCV with fftw3 Visual Studio 2010

耗尽温柔 提交于 2019-12-12 01:08:22

问题


I'm having trouble trying to implement fftw3 with openCV in the same project. I'm new to c/c++ and any help will be much appreciated. The following is just a sample code i used:

 #include "fftw3.h"
 #include <stdlib.h>

 int main(){
     fftw_complex *in, *out;
     fftw_plan p;
     int N=8;
     in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
     out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
     p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
     for(int i=0; i<N; i++){
        in[i][0]=i;
        in[i][1]=0;
     }
     fftw_execute(p);
     for(int i=0; i<N; i++){
            printf("R->%f\tI->%f\n", out[i][0], out[i][1]);
     }
     system("pause");
     fftw_destroy_plan(p);
     fftw_free(in); fftw_free(out);
 }

The code is compiling fine when its in its own project. But when I'm trying to link the fftw3 and openCV together i get a linker error:

    1>video.obj : error LNK2001: unresolved external symbol _fftw_destroy_plan
    1>video.obj : error LNK2001: unresolved external symbol _fftw_execute
    1>video.obj : error LNK2001: unresolved external symbol _fftw_plan_dft_2d
    1>video.obj : error LNK2001: unresolved external symbol _fftw_malloc
    1>video.obj : error LNK2001: unresolved external symbol _fftw_free
    1>D:\C WorkSpace\Viedo_CV\Video test\Release\Video test.exe : fatal error LNK1120: 5 unresolved externals
    1>
    1>Build FAILED.

I double checked all the linker configurations and they seem to be fine(as i said all is working well when in a separate projects). The openCV library is working fine. Unfortunately I can't post my real code. All the openCV i use is in:

    #include <opencv\\cv.h>
    #include <opencv\\highgui.h>
    #include <windows.h>

Any help will be much appreciated.


回答1:


I got it figured out, when I installed openCV I created an environmental variable to the openCV build location and added the openCV DLL's location to the Path variable. What i didn't notice is that I added the x86 version of the DLL's to the Path variable and my project was setup as x64, the reason it worked in another project is because I copied the x64 DLL's to the project folder it self. All worked fine after I edited the Path to the correct x64 DLL's location.



来源:https://stackoverflow.com/questions/17001780/linker-error-using-opencv-with-fftw3-visual-studio-2010

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!