【问题标题】:Cannot find -l<library> R找不到 -l<library> R
【发布时间】:2018-05-19 17:51:22
【问题描述】:

使用 Linux Mint 18.3 (Ubuntu 16.04)

我在 Anaconda 环境中使用 R studio 1.1.383 和 R 3.4.2,在尝试安装多个不同的库时出现编译器错误。

例如,当尝试安装“lmtest”(“tidyquant”的依赖项,它可以毫不费力地安装在我的 Windows 机器上)时,我收到以下错误。由于 tidyquant 有如此多的依赖项,我想省去您的多个错误消息。

install.packages('lmtest')
trying URL 'https://cran.rstudio.com/src/contrib/lmtest_0.9-35.tar.gz'
Content type 'application/x-gzip' length 183575 bytes (179 KB)
==================================================
downloaded 179 KB

installing *source* package ‘lmtest’ ...
package ‘lmtest’ successfully unpacked and MD5 sums checked
libs

/home/mikejames/anaconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran   -fpic  -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -I/home/mikejames/anaconda3/include -L/home/mikejames/anaconda3/lib  -c pan.f -o pan.o

/home/mikejames/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -shared -L/home/mikejames/anaconda3/lib/R/lib -Wl,-O2,--sort-common,--as-needed,-z,relro,-z,now -L/home/mikejames/anaconda3/lib -o lmtest.so pan.o -lgfortran -lm -lgomp -lquadmath -lpthread -L/home/mikejames/anaconda3/lib/R/lib -lR

/home/mikejames/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lgomp

/home/mikejames/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lquadmath

/home/mikejames/anaconda3/lib/R/share/make/shlib.mk:6: recipe for target 'lmtest.so' failed

make: *** [lmtest.so] Error 1

ERROR: compilation failed for package ‘lmtest’
* removing ‘/home/mikejames/anaconda3/lib/R/library/lmtest’
Warning in install.packages :
  installation of package ‘lmtest’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpBzLASQ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

我所有错误消息中的常见错误消息似乎是:找不到-lgomp和-lquadmath

/home/mikejames/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0    /../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lgomp
/home/mikejames/anaconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0    /../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lquadmath

任何帮助将不胜感激!

【问题讨论】:

  • 简答:不要混合使用 anaconda 和 CRAN。
  • 你能解释一下吗?感谢您的快速回复
  • 仅基于我在此处回答的一些先前问题,以及我认识的一个 R 高级用户使用它的事实。 R确实有效。对于 Python,Conda 可能也是如此。两者混合,没有那么多。在基于 .deb 的系统上也不需要它。

标签: r linux ubuntu linux-kernel ubuntu-16.04


【解决方案1】:

不幸的是,如果您正在使用像 QIIME2 这样的大型管道,在 Python 和 R 中都具有非常大且特定的依赖项集,则可能需要将 anaconda/miniconda 与 R 一起使用。(已编辑添加:conda 通常也可用于在您没有 root 访问权限但可能需要访问未安装的特定系统库的集群上运行东西。)我知道这个问题很老了,但它仍然会出现在搜索结果中,所以我认为当我不得不在这些限制下工作时,提供一些对我有用的东西会很有用:

  1. 尝试通过conda install 安装软件包,而不是使用install.packages。 conda 文档建议您使用conda search -f r-[pkgname] 来查找安装候选者。 r 频道可能特别有用。这可能是最简单的方法,但如果您要安装大量软件包并且在许多依赖项中遇到错误,则可能会涉及一些乏味的“打地鼠”。
  2. 查看您遇到的编译错误,然后确保通过 conda 实际安装了必要的库。 “找不到-lgomp”提示需要安装OpenMP;您可以使用 conda install -c conda-forge libgomp 来做到这一点。
  3. 如果步骤 2 仍然不起作用,则 ld 可能正在为您的库寻找错误的位置(即使它应该从您的 conda 环境中获取 LDFLAGS)。这发生在我的 libgomp 身上。受到this question's answers 的启发,我尝试在环境的lib 文件夹中手动创建软链接:ln -s ~/miniconda3/lib/libgomp.so ~/miniconda3/envs/qiime2-2020.6/x86_64-conda-linux-gnu/lib/。这很有效,并且使用 install.packages() 正常安装了软件包。

我想您也可以尝试将-L [/your/home/directory]/miniconda3/lib 添加到您的 LDFLAGS 环境变量中,而不是第 3 步,这可能更优雅,但您必须在每次激活环境时找到一种方法。由于此时我有一个可行的解决方案,因此我没有进一步探索。

希望这些答案有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    • 2017-11-11
    • 2015-02-05
    • 2022-08-06
    相关资源
    最近更新 更多