2012-08-14 40 views
0

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

LINK:致命错误LNK1104:无法打开文件“libfftw3l-3.dll”

我做的dll和lib文件从上所指示的FFTW网站并添加了dll文件到我的项目中Linker> Input> Additional Dep

#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; 
} 
+0

'libfftw3l'是为FFTW的长双倍版本 - 为什么这甚至在你的项目? – 2012-08-14 06:54:17

+0

@ Paul:我只是按照FFTW网站上的说明,所以,你认为我应该从链接器中删除它?我应该在VC++目录还是其他地方添加另一个东西? – Sam 2012-08-14 07:06:45

+0

您需要'libfftw3' DLL,而不是'libfftw3l'或'libfftw3f' DLL。 – 2012-08-14 07:23:35

回答

0

libfftw3l-3.dll对于long double版本FFTW的。它看起来像你的电脑上没有这个文件。但是,由于您不使用任何long double函数或任何单精度函数,因此只需链接libfftw3-3.dll库。