Installation¶
OptimLib is available as a compiled shared library, or as header-only library, for Unix-alike systems only (e.g., popular Linux-based distros, as well as macOS). Note that the use of this library with Windows-based systems, with or without MSVC, is not supported.
Requirements¶
OptimLib requires either the Armadillo or Eigen(3) C++ linear algebra libraries. (Note that Eigen version 3.4.0 requires a C++14-compatible compiler.)
The following options should be declared before including the OptimLib header files.
OpenMP functionality is enabled by default if the
_OPENMP
macro is detected (e.g., by invoking-fopenmp
with GCC or Clang).To explicitly enable OpenMP features, use:
#define OPTIM_USE_OPENMP
To explicitly disable OpenMP functionality, use:
#define OPTIM_DONT_USE_OPENMP
To use OptimLib with Armadillo or Eigen:
#define OPTIM_ENABLE_ARMA_WRAPPERS #define OPTIM_ENABLE_EIGEN_WRAPPERS
Example:
#define OPTIM_ENABLE_EIGEN_WRAPPERS #include "optim.hpp"
To use OptimLib with RcppArmadillo or RcppEigen:
#define OPTIM_USE_RCPP_ARMADILLO #define OPTIM_USE_RCPP_EIGEN
Example:
#define OPTIM_USE_RCPP_EIGEN #include "optim.hpp"
Installation Method 2: Header-only Library¶
OptimLib is also available as a header-only library (i.e., without the need to compile a shared library). Simply run configure
with the --header-only-version
option:
./configure --header-only-version
This will create a new directory, header_only_version
, containing a copy of OptimLib, modified to work on an inline basis.
With this header-only version, simply include the header files (#include "optim.hpp
) and set the include path to the head_only_version
directory (e.g.,``-I/path/to/optimlib/header_only_version``).