在使用GCC编译我的简单C ++程序时遇到了一个奇怪的错误,这里是详细信息:
我有一个名为ware
的抽象类,它有一个名为run()
的虚函数,router
类实现了这个抽象类。我用make
编译它们,我得到一个奇怪的错误。让我们看看下面的所有代码:
ware.h
class ware {
public:
virtual void run() = 0;
};
router.h
#include "ware.h"
class router: ware {
public:
void run();
};
router.cc
#include "router.h"
void router::run() {
// do something
}
这是我的makefile
all: clean build
build:
gcc router.cc main.cc -o main
clean:
rm -rf main
当我尝试编译时,我收到了这个错误:
gcc router.cc main.cc -o main
Undefined symbols for architecture x86_64:
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for ware in router-da2a57.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__vmi_class_type_info", referenced from:
typeinfo for router in router-da2a57.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build] Error 1
任何人都可以帮我查看一下并告诉我我做错了什么吗?在makefile
中配置GCC时,我是否犯了错误?
非常感谢你:(