libMad is a metapackage used to compile a shared library which contains a c interface for MadNLP.
It is currently very much a work in progress.
As it currently stands we require several environment variables to be set when using libMad, to handle several issues coming from upstream Julia packages.
The following are necessary for any interface:
JULIA_CUDA_USE_COMPAT="false"This is necessary to make sure thatCUDA_Driver_jlldoes not attempt to fork a second julia process which fails as the binary does not exist.JULIA_HSL_LIBRARY_PATH="path/to/hsl/lib"This is necessary to use the HSL linear system solvers:Ma*7Solver.JULIA_CUDSS_LIBRARY_PATH="path/to/cudss/lib"This may be necessary if theCUDA_Runtime_Discoverypackage cannot find the cuDSS libraries.
And then several language specific issues may occur if the shared library is loaded through, e.g., the CasADi interface for python or Matlab:
If using the library through a python interface it may be necessary to set the following preload:
LD_PRELOAD="/path/to/libmad/bundle/julia/libssl.so"This is necessary as python may load a different version oflibsslthan the one thatlibMadwas compiled against. This leads to a failure during dynamic loading and a crash.
If using the library through a matlab interface it is necessary to set the following preload:
LD_PRELOAD="/path/to/libmad/bundle/julia/libunwind.so"This is necessary because Matlab ships it's own modified version oflibunwindwhich causes segfaults during backtrace generation inlibMad. Be warned that this breaks the Matlab debugger, causing hard-crashes when attempting to open the debugger.
Requires Julia 1.12+ and the JuliaC.jl package.
The JuliaC.jl app should be installed and a work around for JuliacLang/JuliaC.jl#13 implemented, i.e., add :$JULIA_LOAD_PATH to the shim where the JULIA_LOAD_PATH is loaded.
Checks for these requirements are not currently failing the cmake.
To build:
mkdir build
cd build
cmake ..
makeWhich makes the library as well as a basic executable.