小编rob*_*chm的帖子

无法链接到fftw3库

我正在编译测试程序来测试fftw3(ver3.3.4).由于它没有安装root previlidge,我使用的命令是:

gcc -lm -L/home/my_name/opt/fftw-3.3.4/lib/ -I/home/my_name/opt/fftw-3.3.4/include/ fftwtest.c
Run Code Online (Sandbox Code Playgroud)

安装库的位置

/home/my_name/opt/fftw-3.3.4/
Run Code Online (Sandbox Code Playgroud)

我的代码是fftw3网站上的第一个教程:

#include <stdio.h>
#include <fftw3.h>
int main(){
    int n = 10;
    fftw_complex *in, *out;
    fftw_plan p;

    in = (fftw_complex*) fftw_malloc(n*sizeof(fftw_complex));
    out = (fftw_complex*) fftw_malloc(n*sizeof(fftw_complex));
    p = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE);

    fftw_execute(p); /* repeat as needed */

    fftw_destroy_plan(p);

    fftw_free(in); fftw_free(out);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我编译程序时它会返回以下错误:

/tmp/ccFsDL1n.o: In function `main':
fftwtest.c:(.text+0x1d): undefined reference to `fftw_malloc'
fftwtest.c:(.text+0x32): undefined reference to `fftw_malloc'
fftwtest.c:(.text+0x56): undefined reference to `fftw_plan_dft_1d'
fftwtest.c:(.text+0x66): undefined reference to `fftw_execute'
fftwtest.c:(.text+0x72): undefined reference …
Run Code Online (Sandbox Code Playgroud)

c linker linker-errors fftw

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×1

fftw ×1

linker ×1

linker-errors ×1