S-Function Compiling


I recently installed MATLAB R2015b, and also downloaded the latest version of FAST.

I need to run the simulations in Simulink, however due the different MATLAB version which is used to compile, I need to re-compile the .mex file. For that, I installed MinGW-w64 from mathworks; but still I have a problem in compiling. The script I used to compile .mex file is the one which is contained at FAST folder:

mex -v -L…/…/bin -lFAST_Library_x64 …
-I…/…/Source -I…/…/Source/dependencies/OpenFOAM -outdir …/…/bin COMPFLAGS=’$COMPFLAGS /MT’ FAST_SFunc.c

Which will be resulted in the following error at the middle of compiling:

Error using mex
undefined reference to `min’
collect2.exe: error: ld returned 1 exit status

Error in create_FAST_SFunc (line 7)
mex -v -L…/…/bin -lFAST_Library_x64 …

Please let me know how I can correct it.


I have not tried to compile this with MinGW-w64; from the error message, it looks like the compiler doesn’t have a min() routine.
You could

  1. download the (free) Microsoft Visual Studio Community compiler, which is what I use
  2. create your own min() function, or
  3. comment out line 173 of FAST_SFunc.c and just make sure you don’t initialize the SFunc in Matlab with NumAdditionalInputs greater than 2.