簡體   English   中英

無法安裝 nloptr (R 4.0.3, Ubuntu 20.04)

[英]Cannot install nloptr (R 4.0.3, Ubuntu 20.04)

我嘗試在 R 4.0.3 上安裝 nloptr,但是我收到此錯誤:

/usr/bin/ld: /usr/local/lib/libnlopt.a(general.o): relocation R_X86_64_TPOFF32 against `nlopt_srand_called' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libnlopt.a(mt19937ar.o): relocation R_X86_64_TPOFF32 against `mti' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libnlopt.a(timer.o): relocation R_X86_64_TPOFF32 against `start_inited.4301' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/giovanni/R/x86_64-pc-linux-gnu-library/4.0/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

有人可以指出我的解決方案嗎?

提前致謝。

The latest (2.6.2) package of libnlopt-dev is broken in Ubuntu 20, for some reason it is compiled into a static library (.so shared object is missing) I faced the similar problem a couple of days ago. 快速解決方法是從 Github 下載 NLOPT 並自己編譯https://nlopt.readthedocs.io/en/latest/NLopt_Installation/至少,它對我有用。

我對這個 package 有一個稍微相關的問題, apt install cmake由 cli 本身建議解決了這個問題。

在此處輸入圖像描述

我也未能安裝 nloptr 但有另一個錯誤。

g++: error: nlopt/lib/libnlopt.a: No such file or directory

我按照其他人的建議先安裝 nlopt,如nlopt 網站中所述。 安裝過程是

mkdir build
cd build
cmake ..
make
sudo make install

但是我發現 nlopt 需要的 cmake 版本應該高於 3。我電腦中默認的 cmake 是版本 2.8.12.2 ,即/usr/bin/cmake 所以我在我的主目錄中安裝了 cmake 版本 3.24.2 並使用 cmake 的絕對路徑編譯 nlopt 為~/software/install/cmake-3.24.2-linux-x86_64/bin/cmake.. 我使用 sudo 在計算機中安裝 nlopt。 我可以在 /usr/local/lib64 中看到 libnlopt.so libnlopt.so.0 libnlopt.so.0.11.1 文件

當我回去在 R 中安裝 nloptr 時。 它仍然失敗。 我在安裝的output信息中發現了cmake故障。 因此,我將 cmake(版本 3.24.2)添加到.bashrc文件中的 PATH 中,然后成功安裝了 nloptr。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM