C ++保存mat文件,构建日志显示"undefined reference to 'H5Tget_member_type'....................."
c++ save mat file, build log says"undefined reference to 'H5Tget_member_type'....................."
当我使用 CodeBlock 编译一个 c++ 程序以将矩阵保存到 mat 文件中时,以下是在 Linux 上的构建日志。我已经设置了构建选项、链接器设置、链接库、libmat.so、libeng.so libmx.so。在搜索目录中,在选项卡编译器中,我添加"/usr/local/MATLAB/R2011a/extern/include",在选项卡链接器中,我添加"/usr/local/MATLAB/R2011a/bin/glnx86"。构建日志是什么意思?如何解决?
源代码:
#include <string>
#include <iostream>
#include "matrix.h"
#include "mat.h"
using namespace std;
void saveMat(mxArray* m, const string fileName){
MATFile* pmatFile = NULL;
mxArray* pMxArray = NULL;
string whole_name = fileName + ".mat";
pmatFile = matOpen(whole_name.c_str(),"w");
int row_num = mxGetM(m);
int col_num = mxGetN(m);
pMxArray = mxCreateDoubleMatrix(row_num, col_num, mxREAL);
double *data;
data = mxGetPr(m);
mxSetData(pMxArray, data);
unsigned found = fileName.find_last_of("/\");
string name = fileName.substr(found+1);
matPutVariable(pmatFile, name.c_str(),pMxArray);
matClose(pmatFile);}
构建日志:
warning: libmwfl.so, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmat.so, not found (try using -rpath or -rpath-link)
warning: libut.so, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmat.so, not found (try using -rpath or -rpath-link)
warning: libmx.so, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmat.so, not found (try using -rpath or -rpath-link)
warning: libhdf5_hl.so.6, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmat.so, not found (try using -rpath or -rpath-link)
warning: libhdf5.so.6, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmat.so, not found (try using -rpath or -rpath-link)
warning: libmwresource_core.so, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libmwi18n.so, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libmwMATLAB_res.so, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libboost_date_time.so.1.40.0, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libboost_system.so.1.40.0, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libboost_thread.so.1.40.0, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libicudata.so.42, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libicuuc.so.42, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libicui18n.so.42, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
warning: libicuio.so.42, needed by /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Tget_member_type'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `ut_array_length'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5P_CLS_FILE_CREATE_g'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5T_NATIVE_SHORT_g'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `resource_core::BaseMsgID::getName() const'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Pset_type_conv_cb'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Pcreate'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Tcopy'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `ut_ghash_query'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Aget_space'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Sget_simple_extent_dims'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MATLAB::checkDimCommon::nonnegativeSize::nonnegativeSize()'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `utInferInstallRoot()'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MATLAB::checkDimCommon::complexSize::complexSize()'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Eset_auto2'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `utSingleConvert'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `utf16_strlen_lim'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `utGetFormatEndian'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `utf16_strcpy'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Sget_simple_extent_ndims'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Aget_type'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Fcreate'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MATLAB::colon::logicalInput::logicalInput()'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Sset_extent_simple'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Pset_layout'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Sclose'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `utFinite'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `utF2cstr'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Rcreate'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `utFlipFourBytes'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5T_NATIVE_SCHAR_g'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Scopy'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MATLAB::Cell2Struct::InvalidFieldName::InvalidFieldName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Tlock'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Tget_class'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `typeinfo for MathWorks::System::InternalException'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `fl::mem::aligned_heap::instance'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `utLogWarning(utWarningManagerContext*, char const*, char const*, char*, char const*, bool)'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Gunlink'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Tget_nmembers'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `utFree'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `ucnv_reset_4_2'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MATLAB::getReshapeDims::notSameNumel::notSameNumel()'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Acreate2'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MathWorks::I18N::cast(MathWorks::I18N::UnicodeConverterX*)'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `utTmpnam'
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so||undefined reference to `MATLAB::AddField::InvalidFieldName::InvalidFieldName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Aclose'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5T_NATIVE_ULONG_g'
/usr/local/MATLAB/R2011a/bin/glnx86/libmat.so||undefined reference to `H5Pset_deflate'
More errors follow but not being shown.
Edit the max errors limit in compiler options...
=== Build finished: 50 errors, 15 warnings ===
我遇到了同样的问题。
这是因为 libmat 和 libmx 调用同一文件夹中的其他库文件。尝试使用 的链接器选项嵌入路径
-wl,-rpath=LIBRARY_PATH
具体来说,在我的计算机上,我使用以下命令进行编译,它可以工作
g++ -I/usr/local/MATLAB/R2013a/extern/include -L/usr/local/MATLAB/R2013a/bin/glnxa64sourcefile.cpp -o target -lmat -lmx -wl,-rpath=/usr/local/MATLAB/R2013a/bin/glnxa64
我认为您应该将"matlabroot/bin/glnxa64"添加到您的LD_LIBRARY_PATH中,其中"matlabroot"是指MATLAB安装的根文件夹。因此,链接器可以自动找到所需的库,而无需添加太多特定的库依赖项。
相关文章:
- 在全局变量中保存类的实例以重新创建类(创建"backup")
- Difference in displaying cv2 Mat
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- 为什么Mat类的两个对象可以在不重载运算符+的情况下添加
- 无法从Java读取C++中保存的Opencv Mat映像
- 我在将 cv::Mat 保存到 1D 数组时遇到问题
- OpenCV - 在矢量<Mat>中保存垫子
- 将 OpenCV MAT 保存到 TXT 文件作为不带分隔符的十六进制值
- C ++保存mat文件,构建日志显示"undefined reference to 'H5Tget_member_type'....................."
- Haar检测-保存图像的Mat,以便获得并显示前一帧
- cv::imwrite 不保存CV_32FC4 cv::Mat
- 将Mat压缩到Jpeg中,并将结果保存到内存中
- 是否有可能在cv::Mat中保存复杂的数据结构?
- OpenCv:如何保存Mat::Rect到文件
- 如何将openCV cv::Mat保存到图像中而不进行更改
- 如何保存 c++ 可读的 .mat 文件