0
votes

This drives my crazy: I have a simulink model with an s-function generated by the s-function builder. I use some external header and library files (lib/dll) and all works in simulink-normal-mode.

But if I try to run my model in rapid accelerator or try to build the model for code generation I get LNK2019 errors. It seems that for code generation, Simulink does not know about my header-files (include folder) and my lib-files (folder and files) anymore. But I did specify all of these within the mex command for my s-function. Otherwise, the model wouldnt work in normal-mode.

Is there something I did miss that I should do for code generation?

1
mexing an S-function and generating code from a model are 2 very different processes and know nothing about each other. You need to go to the code generation options under the Simulation Parameters and specify the headers and libs under the appropriate options.Phil Goddard
@Phil This does work. Thanks. I did just overlook the settings in this panel and assumed matlab would find the files like it does with m-files. If you post this as an answer, I can accept it.Lemonbonbon

1 Answers

1
votes

With the Microsoft compiler setup I have found it to be very troublesome and causing this error not due to my setup in Matlab, but due to the installation of the MSVC components:

  1. Need to remove the following two packages first (Must Do, Very Crucial) Microsoft Visual C++ 2010 Redistributable -x64 Microsoft Visual C++ 2010 Redistributable -x86
  2. Remove the current .NET framework and install an older version or not
  3. Install the Microsoft SDK 7.1 and this process may take a little bit time
  4. Make sure that the PC has one of the following installed
    • Microsoft C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
    • Visual Studio 2010 Professional or Express