complex_Bessel_function库的编译——与Fortran代码的链接——mex文件



我制作了一个.cpp代码,它使用以下在线库:

复杂的贝塞尔函数。

我想用我的代码制作一个.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;
}

重点是这个库将一些Fortran代码与C++连接起来。例如,sph_besselY函数将调用相应的Fortran代码zbesy_wrap

我是否应该以某种方式编译Fortran函数?我以与网页相同的方式安装了图书馆。此外,我正在将库导入到我的代码中,如下所示:

#include <complex_bessel.h>
要修复此问题,请添加链接器标志-lcomplex_bessel,如下所示:

编译simpleTest.cpp错误

在Code::Blocks IDE中,我在Project->Build Options...->Linker Settings->Other linker options:文本框中设置了此标志
至于mex,我不知道这个mex GUSTAVsolution.cpp -lcomplex_bessel是否能工作,但可以肯定的是,你应该以某种方式添加这个链接器标志!

相关内容

  • 没有找到相关文章

最新更新