Open rdzman opened 4 years ago
We did have a user some time ago who managed to get it to work and intended to package it as a third-party interface. I can't recall what happened though - I guess it was not finished or was never published. Perhaps @bstellato or @imciner2 remembers.
Using the canned build script make_osqp.m
is probably complicating things somewhat. If I look into the CMakeLists.txt
in the main OSQP
repository, the configuration for CMAKE with the Matlab option is mostly just checking for the existence of matlab and configuring mex to use the pre-2018 mxArray interfaces (specifically, right here).
It might be easier instead to first build osqp as a standalone library first outside of Octave. Then try to compile osqp_mex.c
directly via the mex
utility linking directly to the OSQP static library, being sure to specify -DMATLAB_MEXSRC_RELEASE=R2017b
(or whatever is the equivalent on Octave). This is more or less what is happening anyway, just in a single step.
I have just tried the above and confirmed that it works for me on OSX with no modification to the source. The only thing that needs to be done is to 1) compile the osqp static library outside of octave, then 2) use mex
within octave to compile the mex interface file osqp_mex.cpp
, linking to the static library and specifying the path to the osqp headers. No fancy options seem to be required.
I suggest that we leave this open for now though, since it would be nice to implement this directly into the main project CMAKE scripts and/or provide an Octave-compatible build script for one line compilation.
Wonderful! Thanks.
Could you give me an example of the mex
command you used in step 2? Not sure of the syntax required to specify the paths to the library and headers.
if you follow the standard C install described here, then the required headers will be installed by default someplace like /usr/local/include/qdldl
and /usr/local/include/osqp
. The static library will be somewhere like /usr/local/lib/libosqp.a
(note : you want the static one, not the dynamic one with a .dylib
extension or similar).
That's normally enough for OSQP, but in the case of the matlab interface we also use an internal header from the QDLDL linear solver which seems not to get exported on install (maybe this is a bug, which I will report in a separate issue). I had to access it directly (from the osqp-matlab repo) in ./osqp_sources/lin_sys/direct/qdldl/
You can then do this:
mex -I/usr/local/include/osqp -I/usr/local/include/qdldl -I./osqp_sources/lin_sys/direct/qdldl/ osqp_mex.cpp /usr/local/lib/libosqp.a
When doing that I got a warning about the header Matrix.h
(presumably some matlab header) with a case error in the filename. It didn't prevent it from building though.
Exactly what I needed. Thanks! I got it working. But I agree, it would be nice to have this integrated into the main project for easy one-line compilation.
Hi, @goulart-paul , Any update regarding this request?
Has the MEX interface to OSQP been successfully built for GNU Octave? If not consider this a feature request.
I tried following the instructions for building the MATLAB interface under Octave and initially got an error about
verlessThan
not being supported in Octave. After manually eliminating those calls inmake_osqp.m
, I get ...That was on macOS. I got essentially the same error when I tried it on Linux.
I have very little experience with Octave and MEX, but I do know that it is close enough to the MATLAB MEX interface that IPOPT's Matlab interface builds under both MATLAB and Octave.
I suspect that someone with experience could get the build scripts to work in Octave with little effort.