简体   繁体   English

/ usr / bin / ld找不到-lfftw3?

[英]/usr/bin/ld cannot find -lfftw3?

So I am using FFTW 3.3.3. 所以我正在使用FFTW 3.3.3。 While trying to invoke make from the Makefile, I encounter this problem: 尝试从Makefile调用make时,遇到了以下问题:

    /usr/bin/ld: cannot find -lfftw3
    collect2: ld returned 1 exit status
    make: *** [fftw_ex] Error 1

I previously compiled my code directly with: 我以前直接使用以下代码编译了代码:

    gcc -o fftw_ex fftw_ex.c -I$TACC_FFTW3_INC -L$TACC_FFTW3_LIB -lfftw3

and it worked just fine. 而且效果很好。 Here is my Makefile, in case it's needed: 这是我的Makefile,以备不时之需:

    #                     RULES
    EXEC := fftw_ex
    SRC := $(wildcard *.c)
    OBJ := $(SRC)
    #                     OPERATIONS
    CC := gcc
    CFLAGS := -O3 -I$TACC_FFTW3_INC
    LDFLAGS := -L$TACC_FFTW3_LI
    LDLIBS := -lfftw3

    $(EXEC): $(OBJ)
    $(CC) $(LDFLAGS) $(LDLIBS) -g -o $@ $^

    %.o: %.c
            $(CC) $(CFLAGS) -c $<

    #                   PHONY TARGETS
    .PHONY: clean

    clean:
            @echo Cleaning...;rm -rf *.o fftw_ex

Any help would be greatly appreciated! 任何帮助将不胜感激!

Running make should show you the commands it runs, so you can compare that to the command you run by hand. 运行make应该会向您显示其运行的命令,因此您可以将其与手动运行的命令进行比较。 But this 但是这个

  $(CC) $(LDFLAGS) $(LDLIBS) -g -o $@ $^

Should rather make the libraries to link in come after the files to compile: 宁可让要链接的库在文件编译之后出现:

   $(CC) -g -o $@ $^ $(LDFLAGS) $(LDLIBS) 

You can't use $VARIABLE_NAME in a makefile for shell variables, the syntax in a makefile is $(VARIABLE_NAME), so 您不能在makefile中使用$ VARIABLE_NAME作为shell变量,因为makefile中的语法为$(VARIABLE_NAME),所以

CFLAGS := -O3 -I$(TACC_FFTW3_INC)
LDFLAGS := -L$(TACC_FFTW3_LIB)

Make sure the TACC_FFTW3_LIB and TACC_FFTW3_INC are exported from the shell too. 确保TACC_FFTW3_LIB和TACC_FFTW3_INC也从外壳中导出 (Note that you spelled TACC_FFTW3_LI wrong) (请注意,您拼写的TACC_FFTW3_LI错误)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM