Installing nloptr on Linux

前端 未结 7 755
醉话见心
醉话见心 2021-02-01 03:52

I am trying to install the R package nloptr on a CentOS Linux machine that doesn\'t have internet connection as follows:

install.packages(\"/hom         


        
7条回答
  •  伪装坚强ぢ
    2021-02-01 04:15

    When you say [t]his command in turn looks for the following file online you only get half the story. Together with Jelmer, the maintainer of the actual nloptr package, I modified the package to do the following:

    • look for an install libnlopt library, and, if found, use it
    • if not found fall back to the old behaviour and download the library

    So you could simply install nlopt via

     sudo apt-get install libnlopt-dev
    

    (or the equivalent sudo dpkg -i /media/.... pointing to the file from a USB drive etc pp) and then reinstall the nloptr package. It will just work. On my machine:

    edd@max:~$ install.r nloptr         ## install.r is in littler
    trying URL 'http://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
    Content type 'application/x-gzip' length 353942 bytes (345 KB)
    ==================================================
    downloaded 345 KB
    
    * installing *source* package ‘nloptr’ ...
    ** package ‘nloptr’ successfully unpacked and MD5 sums checked
    checking for g++... g++
    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++ accepts -g... yes
    checking how to run the C++ preprocessor... g++ -E
    checking whether we are using the GNU C++ compiler... (cached) yes
    checking whether g++ accepts -g... (cached) yes
    checking for pkg-config... yes
    configure: Now testing for NLopt header file.
    [...]
    checking for nlopt.h... yes
    configure: Suitable NLopt library found.
    configure: creating ./config.status
    config.status: creating src/Makevars
    ** libs
    g++ -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -Wno-unused -pedantic  -c dummy.cpp -o dummy.o
    gcc -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c nloptr.c -o nloptr.o
    g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so dummy.o nloptr.o -lnlopt -lm -L/usr/lib/R/lib -lR
    installing to /usr/local/lib/R/site-library/nloptr/libs
    ** R
    ** inst
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    * DONE (nloptr)
    
    The downloaded source packages are in
            ‘/tmp/downloaded_packages’
    edd@max:~$ 
    

    Note how it compiled only two files from the actual R packages having found the nlopt installation.

提交回复
热议问题