Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matlab remove os path dependency #896

Merged
merged 6 commits into from
Jan 2, 2023

Conversation

JacobDGrunnet
Copy link
Contributor

When generating a Simulink s-function a number of c-files are compiled using the mex compilation setup and these are linked with a library containing the casadi_ext_fun. The compilation of this library does not use mex compilation, but is rather a system call directly to the compiler. For this to work it is required that the compiler used by mex is added to the OS PATH environment variable.

As we need to have another (incompatible) version of gcc in our OS PATH environment variable acados will use this incompatible gcc version to compile the cadasdi_ext_fun library and the linking will subsequently fail.

Jacob Deleuran Grunnet added 3 commits December 2, 2022 15:07
…iable path

Modified building of casadi_ext_fun library such that the gcc version configured for building mex files is used.
This avoids a linking error which happens when a version of gcc different than configured for mex building is in the OS environment PATH variable.
…iable path

Modified building of casadi_ext_fun library such that the gcc version configured for building mex files is used.
This avoids a linking error which happens when a version of gcc different than configured for mex building is in the OS environment PATH variable.
@@ -223,6 +226,13 @@ function ocp_generate_casadi_ext_fun(model_struct, opts_struct)
% build
compile_command = sprintf('"%s" & %s', msvc_env, build_cmd);
else % gcc
%Read the mex C compiler configuration and extract the location
cCompilerConfig = mex.getCompilerConfigurations('C');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command is not available in Octave.

However, it seems that Octave automatically adds a path to compatible gcc version to the PATH environment variable when Octave starts, so it should be possible just to skip all of this if octave is used

Copy link
Member

@FreyJo FreyJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, that's good to know.
I have to admit that I don't have a Casadi compatible Octave version on my machine right now, so I can't really test it.
However, that is why we have the Github tests in place.
Can you just add some ifs to make this work for Octave?
Then the tests should also pass and I will test it for Matlab locally as well.

…ecting compiler in Matlab

This also includes a slight cleanup as it merges two compiler checks (+1 squashed commits)

Squashed commits:

[fe59f9c] Matlab: Fix error when using octave introduced when automatically detecting compiler in Matlab

This also includes a slight cleanup as it merges two compiler checks
@JacobDGrunnet
Copy link
Contributor Author

Seems I fixed the remaining bug :D

Copy link
Member

@FreyJo FreyJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the Octave version! Now all tests pass.
I just did some minor edits and will merge this.

@FreyJo FreyJo merged commit 7c0bf9c into acados:master Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants