Compilation error Mex Interface MacOS

Hi :wave:

When I try to run the ‘minimal_example_ocp.m’ using the Matlab interface I get the following error:

compiling /Users/acados/examples/acados_matlab_octave/getting_started/../../../interfaces/acados_matlab_octave/ocp_get.c
Building with 'Xcode with Clang'.
Error using mex
/Users/acados/examples/acados_matlab_octave/getting_started/../../../interfaces/acados_matlab_octave/ocp_get.c:405:5: error: implicit declaration of function 'blasfeo_unpack_dmat' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                blasfeo_unpack_dmat(nu[ii]+nx[ii], nu[ii]+nx[ii], qp_in->RSQrq+ii, 0, 0, mat_ptr, nu[ii]+nx[ii]);
                                ^
/Users/acados/examples/acados_matlab_octave/getting_started/../../../interfaces/acados_matlab_octave/ocp_get.c:417:4: error: implicit declaration of function 'blasfeo_unpack_dmat' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        blasfeo_unpack_dmat(nv, nv, qp_in->Hv, 0, 0, mat_ptr, nv);
                        ^
/Users/acados/examples/acados_matlab_octave/getting_started/../../../interfaces/acados_matlab_octave/ocp_get.c:443:4: error: implicit declaration of function 'blasfeo_unpack_tran_dmat' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        blasfeo_unpack_tran_dmat(nx[ii], nx[ii+1], qp_in->BAbt+ii, nu[ii], 0, mat_ptr, nx[ii+1]);
                        ^
3 errors generated.


Error in ocp_compile_interface (line 175)
        mex(mex_flags, FLAGS, LDFLAGS, COMPDEFINES, COMPFLAGS, acados_include, acados_interfaces_include, external_include, blasfeo_include, hpipm_include,...

Error in acados_ocp (line 181)
                ocp_compile_interface(obj.opts_struct);

Error in minimal_example_ocp (line 109)
ocp = acados_ocp(ocp_model, ocp_opts);

I am using macOS 12.5.1 with Matlab r2021b.
Any suggestion?

Thanks.

Hi,

maybe something is wrong with the include paths.
I suggest going into debug mode and checking all the inputs of the mex command.

Cheers!

Thanks for your support. The include paths for the mex command seem ok. I find out that the issue has been introduced with commit “Mex interface improvements (#848)” , I guess due to the removal of some include reputed unnecessary.

Note that with gcc on Ubuntu I get just a warning, not an error.
Hope this helps to find and fix the issue.

Thanks.

Hi Francesco,

@FreyJo and I should have fix the issue. You can try out this PR 851.

Let us know it is working also for you.
I am using macOS 12.3.1 with Matlab r2021b.

Cheers!

Thank you Andrea! The PR 851 fixed the issue but still some include is missing. You can check it out by generating the templated C code (last line in minimal_example_ocp.m). I get this error:

main_pendulum.c:168:5: error: implicit declaration of function 'd_print_exp_tran_mat' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    d_print_exp_tran_mat( NX, N+1, xtraj, NX);
    ^

Thanks.

Thanks for reporting!
I added one more commit on the PR to address this last issue.
Let us know if everything works now :slight_smile:

Yes, everything is working now! Thanks again :slightly_smiling_face:

Hello everyone.

I have a similar issue when I am trying to run any example from the getting_started folder in acados. Below is the error I’m facing for one such example. I have tried installing the acados couple of times according to the installation guide to see if I have missed anything. Also, I have gone through all the files for Mex interface improvements and Fix Matlab interface mac #851 but everything seems ok. I even tried with CMake -DACADOS_INSTALL_DIR=$HOME while installing. But nothing has helped me to solve this issue. Let me know if you have any idea about how to fix this error.

>> extensive_example_ocp
Warning: Name is nonexistent or not a directory: /Users/raghuboppana/../pendulum_on_cart_model 
> In path (line 109)
In addpath (line 86)
In extensive_example_ocp (line 37) 
compiling /Users/raghuboppana/acados/examples/acados_matlab_octave/getting_started/../../../interfaces/acados_matlab_octave/ocp_create.c
2022-09-15 18:44:38.109 xcodebuild[1560:40729] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-09-15 18:44:38.109 xcodebuild[1560:40729] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-09-15 18:44:38.618 xcodebuild[1565:40769] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-09-15 18:44:38.618 xcodebuild[1565:40769] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
Building with 'Xcode with Clang'.
2022-09-15 18:44:41.279 xcodebuild[1570:40821] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-09-15 18:44:41.279 xcodebuild[1570:40821] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore

Error using mex
ld: library not found for -lacados
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Error in ocp_compile_interface (line 175)
        mex(mex_flags, FLAGS, LDFLAGS, COMPDEFINES, COMPFLAGS, acados_include, acados_interfaces_include, external_include, blasfeo_include, hpipm_include,...

Error in acados_ocp (line 181)
                ocp_compile_interface(obj.opts_struct);

Error in extensive_example_ocp (line 240)
ocp = acados_ocp(ocp_model, ocp_opts);

I am using macOS 12.6 with MATLABR2022a and Xcode 14.

Thanks

Hi @raghuboppana

this issue is not the same, so IMO would be better to make a separate post.
It seems that the acados library is not found.
Did you compile them successfully?
Are the libs in <acados_root_folder>/lib?

Cheers!