解决Linux下编译Intel oneTBB动态库出错的问题
在CMakeLists.txt中,原来有一段这样查找和链接的配置代码
find_library(tbblibaray ${tbb_path})
target_link_libraries(backalarm ${tbblibaray})
编译后提示错误:
/myapp/library/tbb/libtbb.so:对‘__cxa_throw_bad_array_new_length@CXXABI_1.3.8’未定义的引用
/myapp/library/tbb/libtbb.so:对‘std::out_of_range::out_of_range(char const*)@GLIBCXX_3.4.21’未定义的引用
/myapp/library/tbb/libtbb.so:对‘std::runtime_error::runtime_error(char const*)@GLIBCXX_3.4.21’未定义的引用
/myapp/library/tbb/libtbb.so:对‘std::length_error::length_error(char const*)@GLIBCXX_3.4.21’未定义的引用
/myapp/library/tbb/libtbb.so:对‘std::invalid_argument::invalid_argument(char const*)@GLIBCXX_3.4.21’未定义的引用
/myapp/library/tbb/libtbb.so:对‘std::runtime_error::runtime_error(char const*)@GLIBCXX_3.4.21’未定义的引用
查找了很多文章,有的说GCC版本太低之类的,没有CXXABI_1.3.8和GLIBCXX_3.4.21之类的。但经查询是有相应版本的:
[root@node58 /]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.6
GLIBC_2.4
GLIBC_2.3.2
[root@node58 /]# strings /usr/lib64/libstdc++.so.6|grep CXXABI
CXXABI_1.3
CXXABI_1.3.1
CXXABI_1.3.2
CXXABI_1.3.3
CXXABI_1.3.4
CXXABI_1.3.5
CXXABI_1.3.6
CXXABI_1.3.7
CXXABI_1.3.8
CXXABI_1.3.9
CXXABI_1.3.10
CXXABI_1.3.11
CXXABI_1.3.12
CXXABI_TM_1
CXXABI_FLOAT128
最后在查询Intel官网oneTBB的github发现,最低系统要求里居然没有CentOS,并且编译器gcc版本要求8-12版本
https://www.intel.com/content/www/us/en/developer/articles/system-requirements/intel-oneapi-threading-building-blocks-system-requirements.html
Software - Supported Operating Systems
Systems with Microsoft* Windows* operating systems
Microsoft* Windows* 10
Microsoft* Windows* 11
Microsoft* Windows* Server 2019
Microsoft* Windows* Server 2022
Systems with Linux* operating systems
Oracle Linux* 8
Amazon* Linux 2, 2022
Rocky Linux 8, 9
Debian* 9, 10, 11
Fedora* 36, 37, 38
Red Hat* Enterprise Linux* 8, 9
SuSE* Linux* Enterprise Server 15
Ubuntu* 20.04, 22.04
Systems with macOS* operating systems
macOS* 12.x, 13.x
Intel® oneAPI DPC++/C++ Compiler
Intel® C++ Compiler Classic 2021.1 - 2021.9
Microsoft* Visual C++ 14.2 (Microsoft* Visual Studio* 2019, Windows* OS only)
Microsoft* Visual C++ 14.3 (Microsoft* Visual Studio* 2022, Windows* OS only)
For each supported Linux* operating system, the standard gcc version provided with that operating system is supported
GNU Compilers (gcc) 8.x – 12.x
GNU C Library (glibc) version 2.28 – 2.36
Clang* 6.0.0-13.0.0
至此问题基本明朗,难道真的要升级gcc版本?但是系统适应性没那么高了。后来发现oneTBB的前身为Threading Building Blocks ,最后的版本是Threading Building Blocks 2020 Update 3,于是下载来看,它最低编译器只要gcc4.8符合要求,立即下载后替换原来的include头文件和lib动态链接文件,最后编译成功!
下载地址:
https://github.com/oneapi-src/oneTBB/releases?page=2
参考:
https://blog.csdn.net/m0_47096428/article/details/124251823