私は、次のオンラインライブラリを使用する.cppコードを作っています- Fortranコードとリンク - MEXファイル
私のコードから.mexファイルを作りたいです。私が入力していた場合:
mex GUSTAVsolution.cpp
をMATLABは、次のエラー得られます。これらのエラーが起こる私の機能の
Error using mex
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function `MIEsolution::Spherical_Hankel_function(unsigned int,
std::complex<double>, int)':
GUSTAVsolution.cpp:(.text+0x18c): undefined reference to `zbesh_wrap'
GUSTAVsolution.cpp:(.text+0x28e): undefined reference to `zbesh_wrap'
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function `MIEsolution::Spherical_Bessel_function_2k(unsigned int,
std::complex<double>)':
GUSTAVsolution.cpp:(.text+0x3dc): undefined reference to `zbesy_wrap'
GUSTAVsolution.cpp:(.text+0x53d): undefined reference to `zbesj_wrap'
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function `MIEsolution::Spherical_Bessel_function_1k(unsigned int,
std::complex<double>)':
GUSTAVsolution.cpp:(.text+0x7a0): undefined reference to `zbesj_wrap'
GUSTAVsolution.cpp:(.text+0x907): undefined reference to `zbesy_wrap'
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function
`MIEsolution::Differentation_Spherical_Hankel_function(unsigned int, std::complex<double>, int)':
GUSTAVsolution.cpp:(.text+0xb32): undefined reference to `zbesh_wrap'
GUSTAVsolution.cpp:(.text+0xc4f): undefined reference to `zbesh_wrap'
GUSTAVsolution.cpp:(.text+0xd30): undefined reference to `zbesh_wrap'
GUSTAVsolution.cpp:(.text+0xe4d): undefined reference to `zbesh_wrap'
/tmp/mex_7456790284416_24518/GUSTAVsolution.o: In function
`MIEsolution::Differentation_Spherical_Bessel_function(unsigned int, std::complex<double>, int)':
GUSTAVsolution.cpp:(.text+0xfb8): undefined reference to `zbesj_wrap'
GUSTAVsolution.cpp:(.text+0x112b): undefined reference to `zbesy_wrap'
GUSTAVsolution.cpp:(.text+0x1303): undefined reference to `zbesj_wrap'
GUSTAVsolution.cpp:(.text+0x1476): undefined reference to `zbesy_wrap'
GUSTAVsolution.cpp:(.text+0x161a): undefined reference to `zbesy_wrap'
GUSTAVsolution.cpp:(.text+0x1787): undefined reference to `zbesj_wrap'
GUSTAVsolution.cpp:(.text+0x1935): undefined reference to `zbesy_wrap'
GUSTAVsolution.cpp:(.text+0x1aa2): undefined reference to `zbesj_wrap'
collect2: error: ld returned 1 exit status
一つです:
complex<double> MIEsolution::Spherical_Bessel_function_2k(unsigned n,complex<double> z){
complex<double> Sb2k;
Sb2k = sph_besselY(n, z);
return Sb2k;
}
点は、このライブラリには、いくつかを接続しているということですC++によるFortranコード。たとえば、sph_besselY
関数は、適切なFortranコードzbesy_wrap
を呼び出します。
私は何とかFortran関数をコンパイルすると思いますか?私はウェブページと同じ方法でライブラリをインストールしました。また、私はそのように、私のコードにライブラリをインポートしています:ここで提案されているよう
#include <complex_bessel.h>
linkerコマンドを表示する...コンパイル済みのCをコンパイル済みのFortranにリンクします。 Fortranには、USE ISO_C_BINDINGがあります。コンパイラスイッチまたはBIND(C ...)のいずれかを使用するために、末尾のアンダースコアなどのシンボルの問題があります。あなたはおそらく簡単な例が必要です。 FortranにBESSEL関数が組み込まれています。 – Holmz