Acados Interface Error: Unknown MEX argument '-I'

Hello,

I have tried both the Makefile-based and the CMake-base build system, and when trying to run any example from

acados/examples/matlab_mex/

I get the following error:

Error using mex
Unknown MEX argument '-I'.

Error in ocp_compile_mex (line 52)
mex(mex_flags, 'CFLAGS=\$CFLAGS -std=c99 -fopenmp', acados_include, acados_interfaces_include,
                external_include, blasfeo_include, acados_lib_path, '-lacados_c', '-lacore', '-lhpipm', '-lblasfeo',
                mex_files{ii})

Error in acados_ocp (line 21)
ocp_compile_mex();

Error in example_ocp (line 186)

ocp = acados_ocp(ocp_model, ocp_opts);

I am running it on ubuntu with a gcc complier. Many thanks for your help.

Cheers
Armin

Hi Armin.
The ‘-l’ flag is the default in gcc to tell the libraries to link. So my suspect is that somehow your matlab is not configured with gcc as compiler.

Can you give some more details about ubuntu version, gcc version and matlab version?

And can you paste here the output of the following matlab command?
mex.getCompilerConfigurations(‘C’)

Thanks!

Hey Gianluca,

thanks for your answer, here is the info:

ubuntu version

Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial

gcc version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609

matlab Version : R2018a

and the output of the command is
Name: ‘gcc’
Manufacturer: ‘GNU’
Language: ‘C’
Version: ‘’
Location: ‘/usr/bin/gcc’
ShortName: ‘gcc’
Priority: ‘A’
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: ‘’
LinkerVersion: ‘’
MexOpt: ‘/export/home/armin/.matlab/R2018a/mex_C_glnxa64.xml’

for instance CasADi and ACADO code generation work well with my current configuration.

Many thanks!
Cheers
Armin

Hello @ArminN
I think I’ve already seen this problem,
did you run source env.sh before running matlab?
This can happen when the relative enviroment variables are not defined.
See

% get acados folder
acados_folder = getenv('ACADOS_INSTALL_DIR');
mex_flags = getenv('ACADOS_MEX_FLAGS');

% set paths
acados_mex_folder = [acados_folder, '/interfaces/acados_matlab/'];
acados_include = ['-I', acados_folder];

Can you check the content of the Matlab variable acados_folder?

I’m adding a check in the examples, to see if env.sh has been sourced

I guess it will take a few more days to find its way into the master branch.

@ArminN was that the issue at the end?

Sorry for my late reply, now with recent updates this error disappeared. Thanks for your help!