# Compiling SFunction

**URL:** <https://forums.nlr.gov/t/compiling-sfunction/181>\
**Category:** Computer-Aided Engineering Software Tools\
**Created:** [July 13, 2009, 11:39pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181 "2009-07-13T23:39:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam.Pechner](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Adam.Pechner](https://forums.nlr.gov/u/Adam.Pechner)\
**Post date:** [July 13, 2009, 11:39pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181/1 "2009-07-13T23:39:36Z")

</div>

We are trying to compile a SFunction for use in the 2007a edition of Matlab.

First, we had to change the path in the FAST\_mexopts.bat to libraries that existed on our local machine. We changed it to…

set LIBLOC=%MATLAB%\extern\lib\win32\microsoft

Then, when selecting the compiler Compaq Visual Fortran 6.6, the following error occurs after the objects are created.

* * *

→ "link “/out:FAST\_SFunc\_BladedA.dll” /debug /DLL /EXPORT:\_MEXFUNCTION@16 /LIBPATH:“C:\PROGRA~1\MATLAB\R2007\extern\lib\win32\microsoft” libmx.lib libmex.lib libmat.lib /implib:C:\DOCUME~1\ADPECH~1\LOCALS~1\Temp\mex\_6948C805-46CC-4836-1E84-455464CD2B9A\templib.lib /NOLOGO @C:\DOCUME~1\ADPECH~1\LOCALS~1\Temp\mex\_6948C805-46CC-4836-1E84-455464CD2B9A\mex\_tmp.rsp "

LINK : LNK6004: FAST\_SFunc\_BladedA.dll not found or not built by the last incremental link; performing full link  
Creating library C:\DOCUME~1\ADPECH~1\LOCALS~1\Temp\mex\_6948C805-46CC-4836-1E84-455464CD2B9A\templib.lib and object C:\DOCUME~1\ADPECH~1\LOCALS~1\Temp\mex\_6948C805-46CC-4836-1E84-455464CD2B9A\templib.exp

→ “del “FAST\_SFunc\_BladedA.map””

## Could Not Find Z:\Source\2007a\_Files\FAST\_SFunc\_BladedA.map

Do you have any recommendations to solve this issue?

Thanks,  
Adam

---

<div class="post-metadata">

**Author:** ![Jason.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/jason.jonkman/32/3086_2.png) [@Jason.Jonkman](https://forums.nlr.gov/u/Jason.Jonkman)\
**Post date:** [July 14, 2009, 4:33pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181/2 "2009-07-14T16:33:57Z")

</div>

Dear Adam,

Sorry, but I’m not sure what the compiling problem is. Does the “\_BladedA” in the file names imply that you are trying to compile the FAST\_SFunc with the Bladed-style DLL interface included?

Best regards,

---

<div class="post-metadata">

**Author:** ![Adam.Pechner](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Adam.Pechner](https://forums.nlr.gov/u/Adam.Pechner)\
**Post date:** [July 14, 2009, 5:01pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181/3 "2009-07-14T17:01:52Z")

</div>

Thanks for the fast response.

Yes the goal was to compile an SFunction as a DLL incorporating changes to multiple code sections because we changed the way the pitch controller works inside simulink. I just wanted to make sure the file name was different from the SFunction.dll that was provided as part of the 2007a.zip download from the NREL forums. If the naming of the file is a problem I can certainly change it.

Adam

---

<div class="post-metadata">

**Author:** ![Jason.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/jason.jonkman/32/3086_2.png) [@Jason.Jonkman](https://forums.nlr.gov/u/Jason.Jonkman)\
**Post date:** [July 14, 2009, 5:09pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181/4 "2009-07-14T17:09:50Z")

</div>

Adam,

The name of the FAST\_SFunc shouldn’t be a problem. But, I’m not sure I follow you.

The FAST\_SFunc is compiled as a .mexw32 file in MATLAB R2006a and newer. Is the DLL you are refering to the GH Bladed-style DLL controller or the FAST\_SFunc.mexw32 file (which was compiled as a DLL in versions of MATLAB older than R2006a)?

Also, changing the Simulink model shouldn’t require a recompile of the FAST\_SFunc. Changing the FAST\_SFunc is only required if you want to make changes to FAST’s source code (e.g., built-in user-defined routines, equations of motion, etc.).

---

<div class="post-metadata">

**Author:** ![Adam.Pechner](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Adam.Pechner](https://forums.nlr.gov/u/Adam.Pechner)\
**Post date:** [July 14, 2009, 5:49pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181/5 "2009-07-14T17:49:31Z")

</div>

Sorry for not being more explicit.

The reason I believe that I need to recompile the SFunction is that I made changes to five of the source files: AeroMods, FAST\_IO, GenSubs, ModCVF, and SysCVF. The file extension has seemed not to be an issue because I have tried both .dll and .mexw32 and while I cannot compile the SFunction under either name, they both run inside the Simulink model.

Thanks,  
Adam

---

<div class="post-metadata">

**Author:** ![Jason.Jonkman](https://dub1.discourse-cdn.com/nrel/user_avatar/forums.nlr.gov/jason.jonkman/32/3086_2.png) [@Jason.Jonkman](https://forums.nlr.gov/u/Jason.Jonkman)\
**Post date:** [July 14, 2009, 6:22pm UTC](https://forums.nlr.gov/t/compiling-sfunction/181/6 "2009-07-14T18:22:52Z")

</div>

Changing the source code will require a recompile of the FAST\_SFunc. But how does the FAST\_SFunc run in Simulink if you haven’t been able to compile it?

MATLAB adds the .mexw32 extension to the FAST\_SFunc when it is compiled using the the MATLAB mex command in make\_FAST\_SFunc.m. I don’t think you have choice of whether it is a .dll or .mexw32 file.
