Matlab mex: More elegant way to setup

The way we need to generate library paths with seem really clunky - basically, I either need to use the folder
to store my own examples, or modify this file by hand…

And if I’m doing that, woudln’t there be a better solution, once I know where my acados is? Thus far I’ve simply hard-coded the path to acados folder, but still run the every time before opening matlab…

Can we instead place this somewhere in bash and make it run once our system starts? What would be the downsides of that? (sorry, I’m not an expert in Linux)

Hello Anton,
You are totally free to add acados related to your ~/.bashrc or equivalent,
the was meant to work in the general case without requiring users to mess with their shell configuration files.
For more involved users the natural next step is to add lines or includes in ~/.bashrc
I would add something like:

export ACADOS_INSTALL_DIR=<your/acados/path/(the one cotaining lib/ and include/)> 
export ACADOS_SOURCE_DIR=<your/acados_source/path> 
# casadi and mex path
export MATLABPATH=$MATLABPATH:$ACADOS_SOURCE_DIR/external/casadi-matlab/
export MATLABPATH=$MATLABPATH:$ACADOS_SOURCE_DIR/interfaces/acados_matlab_octave/
export MATLABPATH=$MATLABPATH:$ACADOS_SOURCE_DIR/interfaces/acados_matlab_octave/acados_template_mex/
# acados shared library
# ocp description and non-linear functions libraries
MODELS=('<path/to/ocp1' '<path/to/ocp2>' '...' ) # assuming ocp descriptions are not necessarily in the acados/examples folder 
for MODEL in "${MODELS[@]}"; do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MODEL/build; done

I agree this is not so “elegant”, but it the only thing we are aware of which can work with MATLAB,
if you know how to set those environment variables (in order to be accessible to the linker ) from MATLAB please let us know

1 Like

Apparently, it’s been like that with Matlab for at least 5 years, good to know that there’s at least one constant in this crazy world :rofl:

1 Like