gpt4 book ai didi

c++保存mat文件,构建日志显示“未定义对 'H5Tget_member_type'的引用......................”

转载 作者:太空宇宙 更新时间:2023-11-04 11:15:59 25 4
gpt4 key购买 nike

当我使用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/glnxa64 sourcefile.cpp -o target -lmat -lmx -Wl,-rpath=/usr/local/MATLAB/R2013a/bin/glnxa64

关于c++保存mat文件,构建日志显示“未定义对 'H5Tget_member_type'的引用......................”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21015452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com