c++ - 在 VC++ 中链接 FFTW 时出错

标签 c++ visual-c++ fftw

我在 VC++ 中使用 FFTW 库并尝试运行此代码。当我运行它时,出现以下错误

LINK : fatal error LNK1104: cannot open file 'libfftw3l-3.dll'

我按照 FFTW 网站上的指示制作了 dll 和 lib 文件,并使用 Linker > Input > Additional Dep 将 dll 文件添加到我的项目中。

#include <fftw3.h>
#include <math.h>

int main(void)
{
    fftw_complex *in, *out;
    fftw_plan p;
    int nx = 5;
    int ny = 5;
    int i;
    float M_PI = 3.14;

    /* Allocate the input and output arrays, and create the plan */
    in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * nx * ny);
    out = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * nx * ny);
    p = fftw_plan_dft_2d(nx, ny, in, out, FFTW_FORWARD,
FFTW_ESTIMATE);

    /* Now fill the input array with the input data */
    /* We'll simply make a sine wave */
    for (i = 0; i < (nx * ny); i++) {
        in[i][0] = sin(i / 10.0 * M_PI);    /* Real part */
        in[i][1] = 0.0;                          /* Imaginary part */
    }

    /* Actually execute the plan on the input data */
    fftw_execute(p);

    /* Print out the results */
    for (i = 0; i < (nx * ny); i++)
        printf("Coefficient %d: %f%+f*i\n", i, out[i][0], out[i][1]);

    /* Clean up after ourselves */
    fftw_destroy_plan(p);
    fftw_free(in); fftw_free(out);
    return 0;
} 

最佳答案

libfftw3l-3.dll 用于 FFTW 的 long double 版本。您的计算机上似乎没有此文件。但是,由于您不使用任何 long double 函数或任何单精度 float 函数,您只需要链接到 libfftw3-3.dll 图书馆。

关于c++ - 在 VC++ 中链接 FFTW 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11945872/

相关文章:

c++ - 使用 FFTW 并评估生成的傅里叶级数

visual-c++ - Visual C++ Redistributable for Visual Studio 2017 的 MSM 文件在哪里?

c++ - 将结构向前声明为类时出现 Visual C++ 2015 链接器错误

c - FFTW 结果与 MATLAB 中的 FFT 不同

c++ - Qt在build debug时将文件夹名中的release替换为debug

c++ - #pragma AVRT_CODE_BEGIN - 这是什么意思?

c - Mac OS X Mavericks 问题上的 FFTW

c++ - NS3 - G++ 6.x 关于 c++14 的警告

C++ 编译错误消息未在 PuTTY 中正确显示

c++ - 未在此范围内声明 - Arduino