2014-11-06 38 views
0

在試圖編譯鏗鏘3.5的C++源代碼文件的未定義行爲檢查鏘未定義行爲檢查鏈接錯誤

clang++-3.5 -std=c++11 -fsanitize=undefined main.cpp 

我在聯收到以下錯誤:

Undefined symbols for architecture x86_64: 
    "typeinfo for __cxxabiv1::__class_type_info", referenced from: 
     __ubsan::checkDynamicType(void*, void*, unsigned long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
     isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
     findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
    "typeinfo for __cxxabiv1::__si_class_type_info", referenced from: 
     isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
     findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
    "typeinfo for __cxxabiv1::__vmi_class_type_info", referenced from: 
     isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
     findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) 
ld: symbol(s) not found for architecture x86_64 

我是否需要鏈接一個額外的庫?

回答

2

看來你是失蹤libc++abi。嘗試添加

-lc++abi 

到您的鏈接命令。