Static or Dynamic Library for S-function

4 views (last 30 days)
Qusay Hawari
Qusay Hawari on 30 Nov 2021
Answered: Pratyush on 17 May 2024
Hi,
I am trying to create an S-function to link OpenFAST with Simulink.
I succefully compiled the build libraries using CMake (on Mac OS).
However as I compiled the main .m file to create the Sfunction is face this error:
I read here https://github.com/OpenFAST/openfast/issues/208 that the issue can be due to the use of static (.a) libraries instead of synamic (.dylib).
My question is that can I create the Sfunction with static librairies, if so, how can I fix the issue?
Thanks in Advance
Qusay.

Answers (1)

Pratyush
Pratyush on 17 May 2024
Hi Qusay,
To create an S-function in MATLAB/Simulink that links with OpenFAST using static libraries (.a) on macOS, follow these steps:
  • Ensure static libraries are compiled for the correct target architecture and version of macOS, specifying architecture flags if necessary.
  • Write your S-function using the appropriate MATLAB API, typically the MEX-function API for C/C++ code.
  • Include static libraries and necessary directories in your "mex" compilation command, specifying include paths, library paths, and the library names.
  • Manually link all dependent static libraries in the correct order since static libraries don't automatically include their dependencies.
  • For complex configurations, consider customizing the "mex" build settings through "mexopts.sh" or "mexopts.bat" files to adjust compiler and linker settings.
  • Ensure correct paths, compatible architectures between libraries and the S-function.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!