Compiling SFunction

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 “””

Could Not Find Z:\Source\2007a_Files\

Do you have any recommendations to solve this issue?


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,

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 download from the NREL forums. If the naming of the file is a problem I can certainly change it.



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.).

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.


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.