Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@FreyJo
Copy link
Member

@FreyJo FreyJo commented Feb 5, 2024

@alextuma
Copy link

alextuma commented Feb 6, 2024

The MSVC version could be implemented with the mex compiler configurations:

msvc_ver_str = "Visual Studio " + mexOpts.Version(1:2) + " " + mexOpts.Name(22:25);
[ status, result ] = system(['cmake -G "' + msvc_ver_str + '" -A x64 -DCMAKE_BUILD_TYPE=Release -DBUILD_ACADOS_OCP_SOLVER_LIB=ON -S . -B .']);

Unfortunately the compilation fails, because the path written into CMakeLists {{ code_export_directory }} contains backslashes.

Error using acados_template_mex.compile_ocp_shared_lib
Generating buildsystem failed.
Got status 1, result: -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22631.
CMake Error at CMakeLists.txt:57 (set):
  Syntax error in cmake code at

    C:/Diplomarbeit/_Matlab/acados/examples/acados_matlab_octave/getting_started/c_generated_code/CMakeLists.txt:57

  when parsing string

    C:\Diplomarbeit\_Matlab\acados\examples\acados_matlab_octave\getting_started\c_generated_code

  Invalid character escape '\D'.


-- Configuring incomplete, errors occurred!


Error in ocp_generate_c_code (line 279)
    acados_template_mex.compile_ocp_shared_lib(obj.acados_ocp_nlp_json.code_export_directory)

Error in acados_ocp (line 203)
            ocp_generate_c_code(obj);

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

I tried to replace the backslashes with slashes in the function call render_file(...) in line 182 in render_acados_templates.m but it didn't change anything. It looks like t_renderer converts the path back to the windows-default format.
I also tried to convert the path in cmake, but with no success:

 set(code_export_dir "{{ code_export_directory }}")
 cmake_path(SET code_export_path "${code_export_dir}")
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE code_export_path)
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE code_export_path)
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE code_export_path)

Do you have a better idea?

@FreyJo
Copy link
Member Author

FreyJo commented Feb 6, 2024

I tried to change the path to unix style in the template logic.
Can you test if that works?

@alextuma
Copy link

alextuma commented Feb 6, 2024

I tried it and it works 👍

@FreyJo
Copy link
Member Author

FreyJo commented Feb 6, 2024

Great, thanks for checking!

@FreyJo FreyJo changed the title fix MEX with MSVC fix MEX with MSVC for OCP Feb 6, 2024
@alextuma
Copy link

alextuma commented Feb 8, 2024

Today i tried it with Visual Studio 14 2015, and it works when the assert(...) command is removed/commented out.
Looks like they changed the folder hierarchy with the newer versions of Visual Studio.
vcvars64.bat does exist, but it is in VC\bin\amd64.

@FreyJo FreyJo changed the title fix MEX with MSVC for OCP fix Matlab with MSVC Feb 12, 2024
@FreyJo
Copy link
Member Author

FreyJo commented Feb 12, 2024

Thanks, I removed the assert and also fixed it for the integrator now :)

@FreyJo FreyJo merged commit 76b7df6 into acados:master Feb 12, 2024
@FreyJo FreyJo deleted the mex_msvc branch February 12, 2024 14:14
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.

2 participants