【发布时间】:2017-03-12 15:53:26
【问题描述】:
我基本上被我想测试的程序之一卡住了,因为我一直收到这个符号未找到错误。
我的程序很简单,在 C++ 方面我是一个极端的初学者,所以我只是想学习一些继承的东西。下面是程序的结构:
The object diagram of the program
所以这很简单,我有 2 个抽象类,即 Vehicle.h 和 MotorVehicle.h , Bus 和 Car 将继承 MotorVehicle.h 的属性 和 Bicycle 将是 Vehicle.h 的后代,因为它不是机动车。
代码和文件非常多,所以如果有人想知道代码,我就把qt项目文件夹留在这里:
https://drive.google.com/open?id=0B1hy9BsfLLwab19wODR2UWhnRmc
现在,由于某种原因,每当我想运行程序时,我都会收到 Symbol(s) not found for architecture x86_64 错误,我检查了 编译输出的 qt Creator,它是这样说的:
Undefined symbols for architecture x86_64:
"vehicle::MotorVehicle::~MotorVehicle()", referenced from:
Car::~Car() in main.o
Bus::~Bus() in main.o
Car::~Car() in Car.o
Bus::~Bus() in Bus.o
"vehicle::Vehicle::~Vehicle()", referenced from:
Bicycle::~Bicycle() in main.o
Bicycle::~Bicycle() in Bicycle.o
"typeinfo for vehicle::MotorVehicle", referenced from:
typeinfo for Car in Car.o
typeinfo for Bus in Bus.o
"typeinfo for vehicle::Vehicle", referenced from:
typeinfo for Bicycle in Bicycle.o
"vtable for vehicle::MotorVehicle", referenced from:
vehicle::MotorVehicle::MotorVehicle(int, int, int, double) in main.o
vehicle::MotorVehicle::MotorVehicle(int, int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, double) in main.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for vehicle::Vehicle", referenced from:
vehicle::Vehicle::Vehicle(int, int, is std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main.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: *** [Vehicles] Error 1
02:38:06: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Vehicles (kit: Desktop Qt 5.8.0 clang 64bit)
When executing step "Make"
我只想说我很困惑,因为我对 C++ 很陌生,我已经尝试从其他 SO 讨论线程中寻找答案,但我只是找不到与我相关的任何内容,所以看起来(或也许我只是还不够努力)
大家好,提前多谢
【问题讨论】: