Clear Filters
Clear Filters

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

33 views (last 30 days)
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サブルーチンの組み込みに挑戦しようと考えておりましたので,何が原因でこのようなエラーが発生してしまうのか,また,どのようにすると解決できるのか知りたいです.
どなたかご教授戴きたく,よろしくお願いいたします.

Accepted Answer

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

More Answers (0)

Categories

Find more on Fortran からの MATLAB の呼び出し in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!