2017-02-06 7 views
1

私は、次のオンラインライブラリを使用する.cppコードを作っています- Fortranコードとリンク - MEXファイル

Complex_Bessel_functions

私のコードから.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> 
+0

linkerコマンドを表示する...コンパイル済みのCをコンパイル済みのFortranにリンクします。 Fortranには、USE ISO_C_BINDINGがあります。コンパイラスイッチまたはBIND(C ...)のいずれかを使用するために、末尾のアンダースコアなどのシンボルの問題があります。あなたはおそらく簡単な例が必要です。 FortranにBESSEL関数が組み込まれています。 – Holmz

答えて

0

が、これはリンカフラグ-lcomplex_besselを追加する修正するには:

コード::ブロックIDE IでCompile simpleTest.cpp errors

Project->Build Options...->Linker Settings->Other linker options:テキストボックスにこのフラグを設定します。
mexについては、この1つが動作するかどうかわかりませんが、どういうわけか、このリンカフラグを追加する必要があります。

+0

OPはCode :: Blocksをどのように使用していますか? –

+0

@VladimirF私はそれを知りません、彼はMatlab mexコンパイラを使用していると思います!しかし、私はg ++とC :​​: Bを使用しているので、 '-lcomplex_bessel'フラグがリンカーにセットされていない限り、それらは同じエラーを出します。したがって、コンパイラとしてMatlabのmexコンパイラにもリンカのフラグを与えるオプションが必要です! – Pekov

関連する問題