Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top