How Can I Generate a 32-bit DLL from a Simulink Model on 64-bit MATLAB?

27 visualizzazioni (ultimi 30 giorni)
I am using a 64-bit MATLAB installation to develop Simulink models on a 64-bit Windows machine, and had been able to build 64-bit DLLs from these models using Visual Studio compilers.
Now, I would like to build those same models as 32-bit DLLs. How could I be able to achieve this?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 17 Gen 2025
Modificato: MathWorks Support Team il 3 Feb 2025 alle 9:54
The best way to set this up is by registering a custom toolchain for your build process. A toolchain is simply a collection of tools used to build the code that gets generated from one of our coder products (in this case Embedded Coder generating code from a Simulink model). Generally speaking, custom toolchain registration can be somewhat involved due to the flexibility in this method, and specifying all of the different aspects can be time-consuming. Fortunately, we already have an example that registers a toolchain for building a 32-bit DLL on a 64-bit Windows machine using Visual Studio. To access the example, execute the following command in the MATLAB command window for release-specific documentation:
>> web(fullfile(docroot, 'coder/ug/build-32-bit-dll-on-64-bit-windows(r)-platform-using-msvc-toolchain.html#responsive_offcanvas'))
The example itself is in the form of a script that registers the toolchain for use with MATLAB Coder, but all toolchains can be used across the Coder products, so it should be suitable for our purposes as well. 
To start, follow the example up until the section titled "Create Code Generation Configuration Object". This means the last command you should have run should be "RTW.TargetRegistry.getInstance('reset');". We don't want to run the whole example because they remove the new toolchain in the cleanup at the end of the example. Notice that there's a 'tc' variable of class Toolchaininfo created in the base workspace.
Then we need to open the Simulink model and make a few modifications to ensure that we are set up properly to use the new toolchain. First, we modify the Hardware implementation to specify that we are targeting a 32-bit Windows computer as seen below:
Next, we need to ensure that we are using "ert_shrlib.tlc" to generate our shared library.
Save the model, close the configuration parameter pane, and reopen it. Then, all we need to do is choose our new toolchain from the list of toolchains:
And then we should be all set to generate a 32-bit DLL.
For more information about custom toolchains, you can refer to the documentation page detailing the various steps of custom toolchain creation and registration. To access this documentation, execute the following command in the MATLAB command window:
>> web(fullfile(docroot, 'coder/ug/what-is-a-custom-toolchain.html'))
Some potential troubleshooting steps: Sometimes after setting the hardware, the toolchain still does not appear under the dropdown. To resolve this, make sure that the hardware settings have been applied, and close the configuration parameters. Reopen the configuration parameters and you should see the toolchain appear as an option. Additionally, saving the model after applying the hardware change can allow the new toolchain to be found.
Please follow the below link to search for the required information regarding the current release:

Più risposte (0)

Categorie

Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by