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

43 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2021-9-22
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). Now generally speaking custom toolchain registration can be somewhat involved as there is a lot of 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! You can find the example at the following documentation page:
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 clean up 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 setup 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 look at the following documentation page detailing the various steps of custom toolchain creation and registration:
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

标签

尚未输入任何标签。

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by