使用openCV与fftw3 Visual Studio 2010的链接器错误(Linker error using openCV with fftw3 Visual Studio 2010)

编程入门 行业动态 更新时间:2024-10-08 02:21:37
使用openCV与fftw3 Visual Studio 2010的链接器错误(Linker error using openCV with fftw3 Visual Studio 2010)

我在同一个项目中尝试使用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.

更多推荐

本文发布于:2023-08-03 14:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1388934.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   链接   Visual   openCV   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!