【问题标题】:"Cannot find -lfftw3_omp" error when compiling a third-party package. How to link the existing library?编译第三方包时出现“找不到 -lfftw3_omp”错误。如何链接现有库?
【发布时间】:2017-11-27 13:31:56
【问题描述】:

我正在尝试在我的 Ubuntu 16.04 系统上编译第三方包,以便在默认 Python 环境的 Anaconda 中使用它。当我运行make 时,编译停止并出现以下错误:

/home/myname/anaconda3/compiler_compat/ld: cannot find -lfftw3_omp
/home/myname/anaconda3/compiler_compat/ld: cannot find -lm
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Makefile:109: recipe for target '_shtns.so' failed
make: *** [_shtns.so] Error 1

Anaconda 似乎无法访问错误消息中提到的两个库。 fftw3_omp.so 库肯定存在于文件夹/home/myname/usr/lib 中。不过,我不确定-lm 是什么。如何正确链接缺失的库?

【问题讨论】:

标签: python makefile anaconda fftw


【解决方案1】:

我得到了类似的错误:

/home/sfchen/anaconda3/envs/dlpy2/compiler_compat/ld:找不到-lpthread /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/ld:找不到-lc

并通过以下步骤解决。

  1. 找到库的根目录(例如 lpthread)

    ld -lpthread --verbose

输出如下:

attempt to open //usr/local/lib/x86_64-linux-gnu/libpthread.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libpthread.a failed
attempt to open //lib/x86_64-linux-gnu/libpthread.so failed
attempt to open //lib/x86_64-linux-gnu/libpthread.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libpthread.so succeeded
opened script file //usr/lib/x86_64-linux-gnu/libpthread.so
opened script file //usr/lib/x86_64-linux-gnu/libpthread.so
attempt to open /lib/x86_64-linux-gnu/libpthread.so.0 succeeded
/lib/x86_64-linux-gnu/libpthread.so.0
attempt to open /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a succeeded
libc.so.6 needed by /lib/x86_64-linux-gnu/libpthread.so.0
found libc.so.6 at //lib/x86_64-linux-gnu/libc.so.6
ld-linux-x86-64.so.2 needed by /lib/x86_64-linux-gnu/libpthread.so.0
found ld-linux-x86-64.so.2 at //lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
ld: warning: cannot find entry symbol _start; not setting start address
  1. 从上面的第 5 行开始

attempt to open //usr/lib/x86_64-linux-gnu/libpthread.so succeeded

获取 path1 = /usr/lib/x86_64-linux-gnu/libpthread.so

  1. 来自错误信息:/home/sfchen/anaconda3/envs/dlpy2/compiler_compat/ld: cannot find -lpthread

获取path2 = /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/

  1. 最后,像这样输入:

    ln -s path1 path2

具体来说,

ln -s /usr/lib/x86_64-linux-gnu/libpthread.so /home/sfchen/anaconda3/envs/dlpy2/compiler_compat/

就这些了,希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-20
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多