MATLAB: Is it possible to use LCC to link FORTRAN and C code in an S-function in Simulink 7.4 (R2009b)

ccodecompilecompilerfortranlcclinkmicrosofts-functionsimulinkvisual

I am trying to create a Simulink Level 2 S-function using the LCC C compiler, and the Compaq Visual Fortran 6.6 compiler. For instance, I am trying to create the S-function from the example files "sfun_atmos.c" and "sfun_atmos_sub.f", located in the directory:
$MATLABROOT\simulink\src
(where $MATLABROOT refers to the root MATLAB directory)
The documentation states that this example can be compiled using the Microsoft Visual C/C++. Since the LCC compiler is shipped with MATLAB, I expect that I should be able to link my Fortran object files and libraries with my C code using LCC. However, I am experiencing problems doing so. Specifically, I receive an error that "sfun_atmos_sub" contains an undefined reference to "__FIIfexp_". I have confirmed that this routine is present in DFOR.LIB, which is located, for instance in C:\Microsoft Visual Studio\DF98\LIB.

Best Answer

The object file formats used by LCC and Microsoft are in general incompatible. They may unpredictably work together on occasion, but may not in other cases.
To work around this issue, try using the Microsoft Visual C/C++ compiler, such as Microsoft Visual C/C++ version 6.0.