Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up| This file describes how to install nloptr from source for Windows. Compiling nloptr for Windows consists of two steps: | |
| 1. configure and compile NLopt from source | |
| or | |
| download and unpack a pre-compiled binary (NLopt-2.4-win-build.zip from http://www.ucl.ac.uk/~uctpjyy/nloptr.html) | |
| 2. compile the R interface | |
| *** To install NLopt from source (optional) | |
| Requirements: Cygwin or MSYS | |
| 1. Download the latest source of NLopt from http://ab-initio.mit.edu/wiki/index.php/NLopt#Download_and_installation, e.g. nlopt-2.4.tar.gz and unpack this archive somewhere (e.g. c:/tmp/nlopt-2.4). | |
| 2. Create a bash script somewhere, e.g. c:/tmp/NLoptInstall.sh with the following contents | |
| #!/bin/bash | |
| R_HOME="C:/tools/R/R-3.0.2" | |
| R_ARCH="i386" | |
| NLOPT_SRC_DIR="C:/tmp/nlopt-2.4" | |
| NLOPT_LIB_DIR="C:/tmp/nlopt" | |
| # Create directory for output | |
| mkdir ${NLOPT_LIB_DIR} | |
| mkdir ${NLOPT_LIB_DIR}/${R_ARCH} | |
| # Start in source directory | |
| cd ${NLOPT_SRC_DIR} | |
| # Get R compilers and flags | |
| CC=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CC` | |
| CFLAGS=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CFLAGS` | |
| CPP=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CPP` | |
| CPPFLAGS=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CPPFLAGS` | |
| CXX=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CXX` | |
| CXXFLAGS=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CXXFLAGS` | |
| CXXCPP=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config CXXCPP` | |
| F77=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config F77` | |
| FFLAGS=`"${R_HOME}/bin/${R_ARCH}/R.exe" CMD config FFLAGS` | |
| echo "./configure --prefix=\"${NLOPT_LIB_DIR}/${R_ARCH}\" --disable-shared --enable-static --without-octave --without-matlab --without-guile --without-python --with-cxx CC=\"${CC}\" ADD_CFLAGS=\"${CFLAGS}\" CPP=\"${CPP}\" ADD_CPPFLAGS=\"${CPPFLAGS}\" CXX=\"${CXX}\" ADD_CXXFLAGS=\"${CXXFLAGS}\" CXXCPP=\"${CXXCPP}\" F77=\"${F77}\" ADD_FFLAGS=\"${FFLAGS}\"" | |
| # Configure | |
| ./configure --prefix="${NLOPT_LIB_DIR}/${R_ARCH}" --disable-shared --enable-static --without-octave --without-matlab --without-guile --without-python --with-cxx CC="${CC}" ADD_CFLAGS="${CFLAGS}" CPP="${CPP}" ADD_CPPFLAGS="${CPPFLAGS}" CXX="${CXX}" ADD_CXXFLAGS="${CXXFLAGS}" CXXCPP="${CXXCPP}" F77="${F77}" ADD_FFLAGS="${FFLAGS}" | |
| # Compile | |
| make | |
| make install | |
| 3. In c:/tmp/NLoptInstall.sh adjust the values of the following macros | |
| R_HOME (The directory where R is located) | |
| NLOPT_SRC_DIR (The directory where the NLopt source is located, i.e. the directory created in 1.) | |
| NLOPT_LIB_DIR (The directory where the NLopt binary will be after compilation. This directory is created by the script NLoptInstall.sh) | |
| 4. Start MSYS, go to the directory where the script is located and execute the bash script | |
| > cd c:/tmp | |
| > ./NLoptInstall.sh | |
| The bash script sets macros for the correct compilers, as used by R, and configures and compiles the NLopt code. You do not need to use the script to compile NLopt, but it simplifies the process. | |
| 5. Optionally compile NLopt for 64-bit. Change the line R_ARCH="i386" to R_ARCH="x64" in c:/tmp/NLoptInstall.sh and execture the script again from MSYS. | |
| *** To install nloptr | |
| Requirements: Rtools | |
| 1. Download the source of nloptr (from GitHub https://github.com/jyypma/nloptr or CRAN http://cran.r-project.org/web/packages/nloptr/index.html) and unpack this somewhere. | |
| 2. Before building from the MS-DOS prompt, define an enviroment variable with the location of the NLopt library, e.g. | |
| set NLOPT_HOME=c:/tmp/nlopt | |
| 3. Compile the R interface | |
| R CMD build nloptr |