部分错误的提示:
/usr/lib/llvm-3.5/lib/libLLVMSupport.a(MemoryObject.o):(.data.rel.ro._ZTVN4llvm12MemoryObjectE[_ZTVN4llvm12MemoryObjectE]+0x28): undefined reference to `__cxa_pure_virtual'
/usr/lib/llvm-3.5/lib/libLLVMSupport.a(MemoryObject.o):(.data.rel.ro._ZTVN4llvm12MemoryObjectE[_ZTVN4llvm12MemoryObjectE]+0x30): undefined reference to `__cxa_pure_virtual'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [helloworld] Error 1
问题的场景:编写分析LLVM中间语言(LLVM IR)的代码,需要对应版本的LLVM库,提供读取和分析LLVM中间语言的API。使用clang链接代码时报错。
问题原因:Makefile中一个配置是CXX=clang-3.5,即使用clang-3.5编译代码,但是代码是C++写的,需要用clang++编译,按我之前的理解,clang和clang++的作用是一样的,但是好像理解错了。
解决办法:使用clang++-3.5编译代码即可,修改配置为CXX=clang++-3.5