我用R语言(3.6),centos7.6环境下安装nloptr包,但是一直报错,也在linux环境下安装了nlopt,cmake,但是一直还是安装不了,求大声支招
```bash
trying URL 'https://mirrors.ustc.edu.cn/CRAN/src/contrib/nloptr_2.0.0.tar.gz'
Content type 'application/octet-stream' length 2219414 bytes (2.1 MB)
==================================================
downloaded 2.1 MB
* installing *source* package ânloptrâ ...
** package ânloptrâ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -m64 -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -m64 -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -m64 -std=gnu++11 accepts -g... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... yes
checking for pkg-config checking NLopt version... insufficient: NLopt 2.7.0 or later is preferred.
using NLopt via local cmake build on x86_64
set CMAKE_BIN=/usr/local/bin/cmake
set CC=gcc -m64 -std=gnu99
set CFLAGS=-I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
set CXX=g++ -m64
set CXXFLAGS=-std=gnu++11 -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
set LDFLAGS=-Wl,-z,relro
which: no ERROR: in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no information in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no for in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no variable in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no 'AR' in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no ERROR: in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no information in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no for in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no variable in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no 'RANLIB' in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
CMake Error: The source directory "/tmp/Rtmp3USN3V/R.INSTALL43d57fd5d69c/nloptr/src/nlopt-build" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Unknown argument -j
Unknown argument 2
Usage: cmake --build <dir> [options] [-- [native-options]]
Options:
<dir> = Project binary directory to be built.
--target <tgt> = Build <tgt> instead of default targets.
--config <cfg> = For multi-configuration tools, choose <cfg>.
--clean-first = Build target 'clean' first, then build.
(To clean only, use --target 'clean'.)
--use-stderr = Don't merge stdout/stderr.
-- = Pass remaining options to the native tool.
CMake Error: The source directory "/tmp/Rtmp3USN3V/R.INSTALL43d57fd5d69c/nloptr/src/nlopt" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I../inst/include -I"/usr/lib64/R/library/testthat/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c init_nloptr.c -o init_nloptr.o
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I../inst/include -I"/usr/lib64/R/library/testthat/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c nloptr.c -o nloptr.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I../inst/include -I"/usr/lib64/R/library/testthat/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c test-C-API.cpp -o test-C-API.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I../inst/include -I"/usr/lib64/R/library/testthat/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c test-runner.cpp -o test-runner.o
g++ -m64 -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/usr/lib64/R/lib -lRlapack -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lquadmath -Lnlopt/lib -lnlopt -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lnlopt
collect2: error: ld returned 1 exit status
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ânloptrâ
* removing â/usr/lib64/R/library/nloptrâ
The downloaded source packages are in
â/tmp/RtmpXTCEuL/downloaded_packagesâ
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("nloptr") :
installation of package ânloptrâ had non-zero exit status
也不知道是不是cmake的原因,反复尝试重新安装了cmake也不行,始终都是一样的报错
```