在C++编译链接过程中,碰到“undefined reference to `vtable for” 有两种排除方法

检查使用的类的基础关系上是否有没有实现的虚函数

示例:

The fix? You've got line(s) like
virtual float getarea() ;
that should read
virtual float getarea() {} ;

The complete (working) source code files for this example are available here

改进建议:在父类里子类会继承重写的成员虚函数加上override;

检查使用的类的库是否被链接

如果没链接,以动态库或者静态库加入到MakeFile 或者CMakeList.txt 中去.示例:

+target_link_libraries(server brpc braft gflags protobuf proto_dbs proto_ebs common log
+configuration your_lib_including_the_code)             # add other lib
+link_libraries("../../libs/project_of_your_lib_including_the_code/output/lib")