我在同一个项目中尝试使用openCV来实现fftw3时遇到了麻烦。 我是c / c ++的新手,非常感谢任何帮助。 以下是我使用的示例代码:
#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); }代码在其自己的项目中编译正常。 但是,当我试图将fftw3和openCV链接在一起时,我得到一个链接器错误:
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.我仔细检查了所有链接器配置,它们似乎没问题(正如我所说,在一个单独的项目中,一切都运行良好)。 openCV库工作正常。 不幸的是我无法发布我的真实代码。 我使用的所有openCV都在:
#include <opencv\\cv.h> #include <opencv\\highgui.h> #include <windows.h>任何帮助都感激不尽。
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.
最满意答案
我弄清楚了,当我安装openCV时,我在openCV构建位置创建了一个环境变量,并将openCV DLL的位置添加到Path变量中。 我没注意到的是我将DLL的x86版本添加到Path变量,我的项目设置为x64,它在另一个项目中工作的原因是因为我将x64 DLL复制到它自己的项目文件夹中。 在我将Path编辑到正确的x64 DLL位置后,一切正常。
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.
更多推荐
发布评论