Fixing WSL errors while generating Linux compatible FMU using FMU Builder

I am trying to generate a Linux compatible FMU using FMU Builder for a Simulink model. The windows version of the FMU is generated withour any errors and it works well. But while generating a Linux compatible FMU, I get an error. I have attached a screenshot of the error below.
I have WSL2 installed on my system (5.15.167.4-microsoft-standard-WSL2).
How do I fix this error?

13 Kommentare

Can you follow the steps mentioned in below documentation link and provide the output that you receive:
Also can you please ensure that you are using correct versions for MATLAB, WSL and FMU Builder support packages as mentioned in the documentation link below:
https://www.mathworks.com/help/slcompiler/ug/fmu-cross-platform-compilation.html
I followed the steps listed in the 1st link you shared. My WSL is already version 2 (it is the latest version 2.5.7.0). I set it to the default version and set the default Ubuntu version to 2 as well.
I also checked the requirements shown in the 2nd link you shared and all the versions satisy the given requirements (I am using Matlab 2024b, FMU Builder 24.2.2 and WSL 2.5.7).
I am still facing the same error even after following these steps.
Any idea what else could be the issue?
Can you please try the following,
  • Run the command "wsl --set-default-version 2" and retry the export to FMU feature.
  • Uninstall existing WSL distros and Reinstall WSL again and retry the export to FMU feature.
Also can you share the output of the following command in windows powershell : "wsl --list".
Also please ensure "Virtual Machine Platform" and "Windows Subsystem for Linux" is enabled in "Turn Windows Features on or off" window.
Upon running the wsl --list command, I am getting the following result:
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
I have already run the "wsl --set-default-version 2" command and the result is the same.
I will try uninstalling and reinstalling the wsl and checking again
I checked on my system and "Virtual Machine Platform" and "Windows Subsystem for Linux" is enabled in "Turn Windows Features on or off" window.
I also tried uninstalling and re-installing WSL2 but I am still getting the same error.
Any idea is a specific distro is required for FMU generation in Matlab Simulink?
Can you also share the output of 'wsl -l -v' command.
Also can you try the following commands:
  • Try running 'wsl --set-default <DistributionName>', replacing <DistributionName> with the name of the Linux distribution you would like to use.
  • Try running 'wsl --set-version <distro name> 2' replacing <distro name> with the name of the Linux distribution
Also please share the outputs of these commands as well.
I tried the commands and I am still facing the same error. I am attaching a screenshot with the results of the 3 commands which you listed in your comment.
Can you try resetting MATLAB's preferences by renaming or deleting the preferences directory (making sure to back it up first). The location can vary, but it's typically found under:
C:\Users\<YourUsername>\AppData\Roaming\MathWorks\MATLAB\
Rename the folder related to your MATLAB version by appending "_backup" to the folder name. MATLAB will recreate the preferences folder with default settings next time it starts.
I followed this path and reset the MATLAB 2024b preferences but I got the same error after doing this as well.
The second error — "Failed to convert WSL1 to WSL2" — might be a consequence of the initial issue: "Failed to import custom distro on Windows Subsystem for Linux."
This could be due to a corrupted installation of the FMU Builder Add-on. I recommend reinstalling the add-on and then attempting to build the FMU executable again.
Additionally, please provide the output of the following command.
wsl -l -q
Following is the output of the command. I tried uninstalling and reinstalling FMU Builder add-on but I am still getting the same error.
Please check the contents of the following directory to see if there is any wsl distro.
Additionally please check if you have the permission to write to this folder
fullfile(matlabshared.supportpkg.getSupportPackageRoot(),'toolbox','shared','simulink','fmubuilder')
I checked the directory and found the distro. But apparently, it was not installed properly (just the distro, not FMU-Builder toolbox). So, I took the assistance of Mathworks support to manually install the distro in the same file path using command prompt. Then I was able to generate the Fmu.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Ashwin
Ashwin am 27 Jun. 2025
The issue was caused by FMU-Builder distro (The WSL distro that comes packaged with FMU Builder toolbox) not getting installed properly. Uninstalling and reinstalling FMU Builder did not fix the issue (I am using FMU Builder Version 24.2.2, maybe this isa glitch in this version itself).
The workaround to the issue is to go to the file path: C/ProgramData/Matlab/SupportPackages/"MatlabVersion"/toolbox/shared/simulink/fmubuilder
and check if the distro folder is available there. If its not, then you need to create a folder called InstallDir and manually install the distro in that file path. This will fix the issue.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Environment Customization finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2024b

Gefragt:

am 27 Mai 2025

Beantwortet:

am 27 Jun. 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by