链接 CXX 共享库失败 - 未定义的引用

Linking CXX shared library fails - undefined reference

提问人:Majo Belda 提问时间:10/16/2023 更新时间:10/16/2023 访问量:31

问:

我正在尝试按照他们的指南安装llvm编译器,并提供以下选项。 在构建它时,我得到了以下错误。cmake -S llvm -B build -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;polly" -DCMAKE_BUILD_TYPE=Release

[ 53%] Linking CXX shared library ../../../../lib/clang/18/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_standalone.so
/usr/bin/ld: CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_itanium.cpp.o: in function `findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)':
/home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:174: undefined reference to `typeinfo for __cxxabiv1::__si_class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:174: undefined reference to `typeinfo for __cxxabiv1::__class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:174: undefined reference to `__dynamic_cast'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:178: undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:178: undefined reference to `__dynamic_cast'
/usr/bin/ld: CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_itanium.cpp.o: in function `isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long)':
/home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:137: undefined reference to `typeinfo for __cxxabiv1::__si_class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:137: undefined reference to `typeinfo for __cxxabiv1::__class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:137: undefined reference to `__dynamic_cast'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:141: undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:141: undefined reference to `typeinfo for __cxxabiv1::__class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:141: undefined reference to `__dynamic_cast'
/usr/bin/ld: CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_itanium.cpp.o: in function `__ubsan::checkDynamicType(void*, void*, unsigned long)':
/home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:245: undefined reference to `typeinfo for __cxxabiv1::__class_type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:245: undefined reference to `typeinfo for std::type_info'
/usr/bin/ld: /home/mbelda/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp:245: undefined reference to `__dynamic_cast'
collect2: error: ld returned 1 exit status
make[2]: *** [projects/compiler-rt/lib/ubsan/CMakeFiles/clang_rt.ubsan_standalone-dynamic-x86_64.dir/build.make:257: lib/clang/18/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_standalone.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:36815: projects/compiler-rt/lib/ubsan/CMakeFiles/clang_rt.ubsan_standalone-dynamic-x86_64.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

我该如何解决这个问题?

我的系统是 Ubuntu 20.04 的全新安装。

我已经缩小了问题出在compiler-rt选项上的范围,因为只有在我添加该选项时才会给出错误。

cmake llvm 链接器错误

评论


答: 暂无答案