当前,我正在尝试在我的大学的服务器上运行由Matlab 2019b构建的Simulink模型,该模型在Linux CentOS 7.3.1611上运行。如果我以“正常”或“加速器”模式运行模型,则表示成功。但是,如果我尝试以“快速加速器模式”运行模型,则编译器将在构建过程中返回错误。这些错误都包含找不到标准库的元素:
undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>
我已经在MATLAB Answers和stackoverflow上搜索了解决方案,但到目前为止,没有一个对我有用。我还向我大学的IT服务寻求帮助,但他们无法帮助我。
One of the solutions提示编译器无法找到正确的库,并且应在堆栈溢出时在此处添加/更新库路径。但是,如果我在matlab中打印“库”路径,那似乎没问题: 库路径:
<matlab_root>/cefclient/sys/os/glnxa64:<matlab_root>/sys/opengl/lib/glnxa64:<matlab_root>/sys/os/glnxa64:<matlab_root>/bin/glnxa64:<matlab_root>/extern/lib/glnxa64:<matlab_root>/runtime/glnxa64:<matlab_root>/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:
<matlab_root>/sys/java/jre/glnxa64/jre/lib/amd64/server:<compiler_root>/root/usr/lib64:<compiler_root>/root/usr/lib:<compiler_root>/root/usr/lib64/dyninst
另一个问题可能是编译器。最初我使用的是gcc 8.x编译器,但后来发现需要6.3版本,所以这就是我现在正在使用的
最后我发现一个问题可能是“(...)它可能表明您正在尝试将使用_GLIBCXX_USE_CXX11_ABI宏的不同值编译的目标文件链接在一起。” (from stack overflow) 最后一种选择对我来说似乎是最有可能的,但是,我无法解决这个问题。例如,我尝试过:
set_param(model,'AccelMakeCommand','make_rtw CPP_OPTS="-D_GLIBCXX_USE_CXX11_ABI=0"')
和
set_param(model,'MakeCommand','make_rtw CPP_OPTS="-D_GLIBCXX_USE_CXX11_ABI=0"')
但是,这没有帮助。
如果任何人都有可以帮助我的提示,那就太好了。我已经添加了控制台输出的一部分,并且出现了错误消息,错误消息如下,以获取更多信息。
亲切的问候, 内森
控制台输出消息:
( A lot of other stuff)
### Processing Template Makefile: <matlab_root>/rtw/c/raccel/raccel_unix.tmf
### <model_folder>/slprj/raccel/MyModel/MyModel.mk which is generated from <matlab_root>/rtw/c/raccel/raccel_unix.tmf is up to date
### Building MyModel: <matlab_root>/bin/glnxa64/gmake -f MyModel.mk RSIM_SOLVER_SELECTION=2 PCMATLABROOT="<matlab_root>" EXTMODE_STATIC_ALLOC=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 EXTMODE_TRANSPORT=0 TMW_EXTMODE_TESTING=0 COMBINE_OUTPUT_UPDATE_FCNS=0 INCLUDE_MDL_TERMINATE_FCN=1 MULTI_INSTANCE_CODE=0 MODELREF_TARGET_TYPE=NONE ISPROTECTINGMODEL=NOTPROTECTING OPTS="-DTGT
an error.
错误消息:
( A lot of stuff)
g++ -Wl,-rpath,<matlab_root>/sys/os/glnxa64
-L<matlab_root>/sys/os/glnxa64 -o MyModel
MyModel_c233cdf9_1.o MyModel_c233cdf9_1_create.o
MyModel_c233cdf9_1_setParameters.o
MyModel_c233cdf9_1_asserts.o
MyModel_c233cdf9_1_deriv.o
MyModel_c233cdf9_1_checkDynamics.o
MyModel_c233cdf9_1_output.o
MyModel_c233cdf9_1_assembly.o
MyModel_c233cdf9_1_computeConstraintError.o
MyModel_c233cdf9_1_mode_zero_crossings.o
MyModel_c233cdf9_1_geometries.o
MyModel_c233cdf9_1_gateway.o pm_printf.o rt_logging.o
rt_backsubrr_dbl.o rt_forwardsubrr_dbl.o rt_lu_real.o rt_matrixlib_dbl.o
MyModel.o MyModel_capi.o
MyModel_data.o MyModel_tgtconn.o rtGetInf.o
rtGetNaN.o rt_nonfinite.o rt_logging_mmi.o rtw_modelmap_utils.o
raccel_main_new.o raccel_sup.o raccel_mat.o simulink_solver_api.o
raccel_utils.o common_utils.o ext_svr.o updown.o ext_work.o
rtiostream_interface.o rtiostream_tcpip.o rtiostream_utils.o \
<matlab_root>/toolbox/physmod/sm/ssci/lib/glnxa64/sm_ssci_std.a
<matlab_root>/toolbox/physmod/sm/core/lib/glnxa64/sm_std.a
<matlab_root>/toolbox/physmod/pm_math/lib/glnxa64/pm_math_std.a
<matlab_root>/toolbox/physmod/simscape/engine/sli/lib/glnxa64/ssc_sli_std.a
<matlab_root>/toolbox/physmod/simscape/engine/core/lib/glnxa64/ssc_core_std.a
<matlab_root>/toolbox/physmod/network_engine/lib/glnxa64/ne_std.a
<matlab_root>/toolbox/physmod/common/math/core/lib/glnxa64/mc_std.a
<matlab_root>/toolbox/physmod/common/external/library/lib/glnxa64/ex_std.a
<matlab_root>/toolbox/physmod/common/foundation/core/lib/glnxa64/pm_std.a
<matlab_root>/bin/glnxa64/libmwcoder_target_services.so
<matlab_root>/bin/glnxa64/libmwcoder_ParamTuningTgtAppSvc.so
-L"<matlab_root>/bin/glnxa64" -lmwipp -lut -lmx -lmex
-lmat -lmwmathutil -lmwslexec_simbridge -lmwsl_fileio
-lmwsigstream -lmwsl_AsyncioQueue -lmwsl_services
-lmwsdi_raccel -lmwi18n -lmwsl_simtarget_instrumentation
-lfixedpoint -lmwslexec_simlog -lm -lpthread -ldl
<matlab_root>/bin/glnxa64/libQt5WebKit.so.5: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_S_copy(char*, char const*, unsigned
long)@GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwboost_locale.so.1.65.1: undefined
reference to `std::__cxx11::numpunct<char>::id@GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwboost_serialization.so.1.65.1:
undefined reference to `typeinfo for
std::__codecvt_utf8_base<wchar_t>@GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libut.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::assign(char const*)@GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libut.so: undefined reference to
`std::logic_error::logic_error(char const*)@GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwcoder_target_services.so: undefined
reference to `typeinfo for std::_V2::error_category@GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwboost_locale.so.1.65.1: undefined
reference to `typeinfo for std::__cxx11::moneypunct_byname<char,
false>@GLIBCXX_3.4.21'
( A lot of stuff)
collect2: error: ld returned 1 exit status
gmake: *** [MyModel] Error 1
Error(s) encountered while building "MyModel" - Show complete
stack trace
}