C-MEX(fortran)のビルドエラー "undefined reference to `ATMOS' collect2.exe: error: ld returned 1 exit status" を解決するためにはどうすればよいですか.

조회 수: 8 (최근 30일)
C-MEX Calling Fortran (S-function) のサンプルsfun_atmos(https://jp.mathworks.com/help/simulink/sfg/s-function-examples.html)に関して,
mex('-v', '-c', fullfile(matlabroot,'toolbox','simulink','sfuntemplates','srcFortran','sfun_atmos_sub.F'))
mex('-v', ['-L"', fullfile(getenv('IFORT_COMPILER24'), 'compiler', 'lib', 'intel64_win'), '"'], fullfile(matlabroot,'toolbox','simulink','sfuntemplates','srcFortran','sfun_atmos.c'), 'sfun_atmos_sub.obj')
このようにコマンドウィンドウで実行したところ,コンパイルと.objファイルの出力には成功したのですが,ビルド時に以下のようなエラーが出てしまいます.
次を使用中のエラー: mex
C:\Users\SSHINS~1\AppData\Local\Temp\mex_1126126941339403_22156\sfun_atmos.obj:sfun_atmos.c:(.text+0x142): undefined reference to `ATMOS'
collect2.exe: error: ld returned 1 exit status
使用環境としては,次の通りです.
windows 10 64bit
MATLAB 2024a
このサンプルに習って自身のfortranサブルーチンの組み込みに挑戦しようと考えておりましたので,何が原因でこのようなエラーが発生してしまうのか,また,どのようにすると解決できるのか知りたいです.
どなたかご教授戴きたく,よろしくお願いいたします.

채택된 답변

N.Y.
N.Y. 2024년 5월 14일
一応,解決したので...
gccベースのコンパイラを使用する際,sfun_atmos.cの60行目のコメントは正しくないようです.
したがって以下の文をコメントアウトすることで,コンパイルが成功しました.
#ifdef _WIN32
#define atmos_ ATMOS
#endif

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fortran からの MATLAB の呼び出し에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!