我正在尝试编写一个非常简单的测试应用程序,它使用Matlab C++接口。我的机器运行的是默认的gcc 4.8.5版本的CentOs7。但是对于我的应用程序,我需要gcc 7+,所以我也安装了gcc 7.3.1。在编译这个迷你应用程序时,我使用以下命令:
g++ -o matlab_test matlab_test.cpp -I/home/matlab/lnx_x64/R2017B/release/inc -L/home/matlab/R2017B/release/lib -lMatlabEngine -lpthread -Wl,-v但我所面对的问题是:
collect2 version 7.3.1 20180303 (Red Hat 7.3.1-5)
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld -plugin /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/liblto_plugin.so -plugin-opt=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper -plugin-opt=-fresolution=/tmp/ccDdzXBy.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o matlab_cpp_test /lib/../lib64/crt1.o /lib/../lib64/crti.o /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o -L/home/matlab/lnx_x64/R2017B/release/lib -L/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 -L/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../.. /tmp/ccsqA2N9.o -lpthread -lMatlabEngine -lstdc++ -v -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/crtend.o /lib/../lib64/crtn.o
GNU ld version 2.28-11.el7
/home/matlb/lnx_x64/R2017B/release/lib/libMatlabEngine.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
collect2: error: ld returned 1 exit status我在其他一些问题(如this )中检查了错误消息。根据答案,我链接到了错误版本的libstdc++。但是,当我检查我的LD_LIBRARY_PATH变量时,它在开始时包含了新libstdc++.so的路径:
[giant@centos-machine test]$ echo $LD_LIBRARY_PATH
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7:/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:/opt/rh/devtoolset-7/root/usr/lib64/dyninst:/opt/rh/devtoolset-7/root/usr/lib/dyninst:/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib有人能给我一些建议吗?我该如何解决这个问题?
发布于 2021-09-30 08:04:21
/opt/rh/devtoolset-7
devtoolset-7:
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/libstdc++.so
.是一个210 B文本文件:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-x86-64)
INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared )/usr/lib64/libstdc++.so.6将被使用。
EL7:how to install gcc 4.9.2 on RHEL 7.4的“其他额外gcc/g++”
https://stackoverflow.com/questions/69343832
复制相似问题