# S-Function Compiling

**URL:** <https://forums.nlr.gov/t/s-function-compiling/1210>\
**Category:** Computer-Aided Engineering Software Tools\
**Created:** [October 23, 2015, 8:34am UTC](https://forums.nlr.gov/t/s-function-compiling/1210 "2015-10-23T08:34:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iman.Yousefi](https://avatars.discourse-cdn.com/v4/letter/i/b9bd4f/32.png) [@Iman.Yousefi](https://forums.nlr.gov/u/Iman.Yousefi)\
**Post date:** [October 23, 2015, 8:34am UTC](https://forums.nlr.gov/t/s-function-compiling/1210/1 "2015-10-23T08:34:55Z")

</div>

Hello!

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  
C:\Users\Iman\AppData\Local\Temp\mex\_14669147854515\_112\FAST\_SFunc.obj:FAST\_SFunc.c:(.text+0xe67):  
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.

Yours,  
Iman

---

<div class="post-metadata">

**Author:** ![Bonnie.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/bonnie.jonkman/32/3230_2.png) [@Bonnie.Jonkman](https://forums.nlr.gov/u/Bonnie.Jonkman)\
**Post date:** [October 30, 2015, 8:05pm UTC](https://forums.nlr.gov/t/s-function-compiling/1210/2 "2015-10-30T20:05:21Z")

</div>

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.
