Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

使用fftw库后编译显示对其中的函数未定义的引用,请问怎么解决?

代码如下

#include <fftw3.h>

int main(){
    
    int N = 10;
    float *in;
    fftw_complex *out;
    fftw_plan p;

    in = (float*)fftw_malloc(sizeof(float) * N);
    out = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N);
    p = fftw_plan_dft_r2c_1d(N, in, out, FFTW_ESTIMATE);
    
    fftw_excute(p);

    fftw_destroy_plan(p);
    fftw_free(in); fftw_free(out);

    return 0;
}

gcc -o demo demo.c编译结果如下
**/tmp/ccD0dQQA.o:在函数‘main’中:
demo.c:(.text+0x1c):对‘fftw_malloc’未定义的引用
demo.c:(.text+0x31):对‘fftw_malloc’未定义的引用
demo.c:(.text+0x4c):对‘fftw_plan_dft_r2c_1d’未定义的引用
demo.c:(.text+0x61):对‘fftw_excute’未定义的引用
demo.c:(.text+0x6d):对‘fftw_destroy_plan’未定义的引用
demo.c:(.text+0x79):对‘fftw_free’未定义的引用
demo.c:(.text+0x85):对‘fftw_free’未定义的引用
collect2: error: ld returned 1 exit status
**


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

clipboard.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...