Compiling OpenFAST S Function on mac

Hi

I successfully compiled open fast using cmake. The cmake flags were:

cmake .. -BUILD_OPENFAST_SIMULINK_API=ON -BUILD_TESTING=ON -BUILD_SHARED_LIBS=ON

Then I modified the MATLAB script create_FAST_SFunc.m with the appropriate paths.

When I execute the script, I got the following error:

[code]----------------------------
Creating ./FAST_SFunc.mexmaci64

Building with ‘Xcode with Clang’.
Error using mex
ld: warning: could not create compact unwind for _FAST_OpFM_Restart: stack subq
instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _FAST_OpFM_Init: stack subq instruction
is too different from dwarf stack size
ld: warning: could not create compact unwind for _FAST_Restart: stack subq instruction
is too different from dwarf stack size
ld: warning: could not create compact unwind for _FAST_CreateCheckpoint: stack subq
instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _FAST_Sizes: stack subq instruction is
too different from dwarf stack size
Undefined symbols for architecture x86_64:
“___extenddftf2”, referenced from:
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Sizes in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_exitthisprogram_t”, referenced from:
_FAST_End in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_fast_createcheckpoint_t”, referenced from:
_FAST_CreateCheckpoint in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_fast_initializeall_t”, referenced from:
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Sizes in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_fast_linearize_t”, referenced from:
_FAST_Update in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Start in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_fast_restorefromcheckpoint_t”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_fast_solution0_t”, referenced from:
_FAST_OpFM_Solution0 in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Start in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_fast_solution_t”, referenced from:
_FAST_OpFM_Step in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Update in libopenfastlib.a(FAST_Library.f90.o)
“___fast_subs_MOD_filloutputary_t”, referenced from:
_FAST_Update in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Start in libopenfastlib.a(FAST_Library.f90.o)
“___netf2”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
“___nwtc_base_MOD_aborterrlev”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Start in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Sizes in libopenfastlib.a(FAST_Library.f90.o)
“___nwtc_io_MOD_int2lstr”, referenced from:
_FAST_CreateCheckpoint in libopenfastlib.a(FAST_Library.f90.o)
“___nwtc_io_MOD_wrscr1”, referenced from:
_FAST_AllocateTurbines in libopenfastlib.a(FAST_Library.f90.o)
“___nwtc_library_MOD_nwtc_init”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
“___nwtc_library_types_MOD_seterrstat”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
“___supercontroller_MOD_sc_setinputs”, referenced from:
_FAST_OpFM_Step in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Solution0 in libopenfastlib.a(FAST_Library.f90.o)
“___supercontroller_MOD_sc_setoutputs”, referenced from:
_FAST_OpFM_Step in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Solution0 in libopenfastlib.a(FAST_Library.f90.o)
“___trunctfdf2”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Update in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Start in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Sizes in libopenfastlib.a(FAST_Library.f90.o)
“__gfortran_concat_string”, referenced from:
_FAST_OpFM_Step in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Solution0 in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_CreateCheckpoint in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Update in libopenfastlib.a(FAST_Library.f90.o)

“__gfortran_os_error”, referenced from:
_FAST_AllocateTurbines in libopenfastlib.a(FAST_Library.f90.o)
“__gfortran_runtime_error_at”, referenced from:
_FAST_DeallocateTurbines in libopenfastlib.a(FAST_Library.f90.o)
_FAST_AllocateTurbines in libopenfastlib.a(FAST_Library.f90.o)
“__gfortran_string_index”, referenced from:
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_CreateCheckpoint in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Sizes in libopenfastlib.a(FAST_Library.f90.o)
“__gfortran_string_len_trim”, referenced from:
_FAST_OpFM_Step in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Solution0 in libopenfastlib.a(FAST_Library.f90.o)
_FAST_OpFM_Init in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Restart in libopenfastlib.a(FAST_Library.f90.o)
_FAST_CreateCheckpoint in libopenfastlib.a(FAST_Library.f90.o)
_FAST_Update in libopenfastlib.a(FAST_Library.f90.o)

“__gfortran_string_trim”, referenced from:
_FAST_CreateCheckpoint in libopenfastlib.a(FAST_Library.f90.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error in create_FAST_SFunc (line 62)
mex(‘-largeArrayDims’, …[/code]

When I first saw the error I thought it was related to the lack of MEX configuration to compile fortran. But I managed to configure gfortran with mex and the error continues the same. For reference, the current output for the “mex -setup -v fortran” matlab command is:

Verbose mode is on. ... Looking for compiler 'Intel Fortran Composer XE' ... ... Looking for environment variable 'IFORT_COMPILER20' ...No. ... Looking for environment variable 'IFORT_COMPILER19' ...No. ... Looking for environment variable 'IFORT_COMPILER18' ...No. ... Looking for environment variable 'IFORT_COMPILER17' ...No. ... Looking for environment variable 'IFORT_COMPILER16' ...No. ... Looking for environment variable 'IFORT_COMPILER15' ...No. ... Executing command 'which ifort' ...No. Did not find installed compiler 'Intel Fortran Composer XE'. ... Looking for compiler 'gfortran' ... ... Looking for environment variable 'DEVELOPER_DIR' ...No. ... Executing command 'which gfortran' ...No. ... Looking for file '/usr/local/bin/gfortran' ...Yes. ... Looking for folder '/usr/local/Cellar/gcc/10.1.0/bin' ...Yes. ... Executing command 'which gfortran' ...No. ... Looking for file '/usr/local/bin/gfortran' ...Yes. ... Executing command '/usr/local/bin/gfortran -print-file-name=libgfortran.dylib' ...Yes ('/usr/local/Cellar/gcc/10.1.0/lib/gcc/10/libgfortran.dylib'). ... Looking for folder '/usr/local/Cellar/gcc/10.1.0/lib/gcc/10' ...Yes. ... Executing command 'xcrun -sdk macosx --show-sdk-path' ...Yes ('/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'). ... Executing command 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.15.4'). Found installed compiler 'gfortran'. ... Looking for compiler 'gfortran' ... ... Looking for environment variable 'DEVELOPER_DIR' ...No. ... Executing command 'which gfortran' ...No. ... Looking for file '/usr/local/bin/gfortran' ...Yes. ... Looking for folder '/usr/local/Cellar/gcc/10.1.0/bin' ...Yes. ... Executing command 'which gfortran' ...No. ... Looking for file '/usr/local/bin/gfortran' ...Yes. ... Executing command '/usr/local/bin/gfortran -print-file-name=libgfortran.dylib' ...Yes ('/usr/local/Cellar/gcc/10.1.0/lib/gcc/10/libgfortran.dylib'). ... Looking for folder '/usr/local/Cellar/gcc/10.1.0/lib/gcc/10' ...Yes. ... Executing command 'xcrun -sdk macosx --show-sdk-path' ...Yes ('/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'). ... Executing command 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.15.4'). Found installed compiler 'gfortran'. MEX configured to use 'gfortran' for FORTRAN language compilation.

Could someone provide me some directions?

My environment is MATLAB R2019b with Catalina (10.15.5).

Dear Pedro,

I have no experience compiling the OpenFAST S-Function on mac with CMake, so, I don’t know the answer to your question. I would suggest that you repost your question on the OpenFAST github site (github.com/OpenFAST/openfast/issues), where OpenFAST compiling-related questions are better supported. The forum better supports usage-related questions.

Best regards,

Dear Jason

Thanks for your prompt response.

I gave up compiling the S Function on Mac and set up a virtual machine with windows. If I eventually come up with a solution in the future I’ll post here.