nlopt
Thin wrapper around the C nlopt
library.
Note: Not all algorithms have been tested.
Docs
Building
This library depends upon nlopt and will fail if it cannot find a library to link against.
For Linux, it is recommended to clone nlopt
from github (the official release is
many years behind master) and follow the installation docs.
You may find it more convenient the build nlopt
as a static library, by passing -DBUILD_SHARED_LIBS=OFF
to cmake
.
Windows is a bit more tricky. One way is to download the precompiled
binary and turn it into nlopt.lib
by executing
lib.exe /def:libnlopt-0.def /out:nlopt.lib /MACHINE:x64`
(This requires the Visual Studio development tools to be installed).
For either platform, the resulting object must be on the search path at link-time. This can be set with
environment variables, the rustc
command or a build.rs
script.
Example rustc
command:
cargo rustc --release -- -L /path/to/nlopt
Example build.rs
:
fn main() {
println!(r"cargo:rustc-link-search=C:\path\to\nlopt");
}
Tests
This can be tricky because it's necessary to pass in linker arguments, and without build.rs
this may
not work with a simple cargo test
command. One quick workaround is:
cargo rustc --tests -- -L /path/to/nlopt
target/debug/nlopt-<SOME-HASH>