R-CMD-check test-coverage Codecov test coverage pkgdown CRAN status

nloptr is an R interface to NLopt, a free/open-source library for nonlinear optimization started by Steven G. Johnson, providing a common interface for a number of different free optimization routines available online as well as original implementations of various other algorithms. It can be used to solve general nonlinear programming problems with nonlinear constraints and lower and upper bounds for the controls, such as

_{x ^n} f(x),

s.t. g(x) , h(x) = 0 and x u.

The NLopt library is available under the GNU Lesser General Public License (LGPL), and the copyrights are owned by a variety of authors. See the website for information on how to cite NLopt and the algorithms you use.



On Windows, either the latest version 2.7.1 of NLopt from rwinlib (windows-release) or the v2.7.1 build from the rtools42 toolchain (windows2022-devel) is used. So there is nothing else to be done.

Linux and macOS

On Unix-like platforms, we use pkg-config to find a suitable system build of NLopt (i.e. with version >= 2.7.0).

Installing CMake (macOS and Linux only)

Minimal version requirement for cmake is 3.2.0.

You can install CMake by following CMake installation instructions. The important thing is that you add the CMake binary to your PATH:

Alternatively, you can set an environment variable CMAKE_BIN pointing to a CMake binary of your liking on your computer for nloptr to use.

Installing nloptr

You can install nloptr from CRAN using:


Alternatively, you can install the development version from GitHub:

# install.packages("remotes")


I would like to express my sincere gratitude to Dirk Eddelbuettel, Jeroen Ooms, Tomas Kalibera, Uwe Ligges and Jelmer Ypma for their contributions and the very instructive discussions about the pros and cons of various build strategies in R packages.


Steven G. Johnson, The NLopt nonlinear-optimization package,