complex_Bessel_function库的编译——与Fortran代码的链接——mex文件
Compiling of complex_Bessel_function library - linking with Fortran code - mex file
我制作了一个.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
是否能工作,但可以肯定的是,你应该以某种方式添加这个链接器标志!
相关文章:
- 为什么这段代码(在 Matlab 的 MEX 文件中使用 OpenMP)给出不同的结果?
- 使用带有 MEX 包装器的帮助程序 C 文件从 MATLAB 2016 调用C++代码时出现问题
- complex_Bessel_function库的编译——与Fortran代码的链接——mex文件
- 为什么在我的 mex 代码中将数组大小标识为零?
- 使用MATLAB通过MEX运行OPENCV代码在VisualStudio上可以使用
- 使用 Matlab Coder 将 Matlab m 文件转换为 C/C++ 代码,包括 mex 文件 (mxArray
- 是否可以将mex代码转换为C++代码
- Matlab在MEX/C代码中阻止或拦截free()吗
- MATLAB 包装器中的 MEX 代码
- 将 C/C++ 代码称为 MEX 文件与纯 C/C++
- Matlab Mex代码未编译
- Visual Studio -如何将matlab中的mex代码转换为c++
- Mex Cuda动态分配/慢速Mex代码
- 如何避免重复初始化.mex (matlab编译代码)
- Mex函数比相同的c++代码更快
- 如果瓶颈是一个大的矩阵乘法,我可以使用mex文件加速我的MATLAB代码吗?
- 如何找到Matlab-mex文件的代码
- 将matlab代码与c/c++代码相结合,使用matlab编码器实现mex函数
- Matlab Mex文件构建:代码更改不再影响mex文件
- 是否可以将C++/MEX(Matlab)代码转换为独立C++