使用qt Creator IDE找不到架构x86_64(C ++)的符号

时间:2017-03-12 15:53:27

标签: c++ qt x86-64

我基本上遇到了一个我想测试的程序,因为我一直都没有找到这个符号。

我的程序很简单,在C ++方面我是一个极端的初学者,所以我只是想学习一些继承的东西。以下是该计划的结构:

The object diagram of the program

所以它非常简单,我有2个抽象类,它们是 Vehicle.h MotorVehicle .h B 我们 汽车 将从 MotorVehicle继承属性 .h Bicyc le 将是 Vehicle.h 的后代,因为它&# 39;不是机动车。

有很多代码和大量文件,所以如果有人想知道这些代码,我会把qt项目文件夹留在这里:

https://drive.google.com/open?id=0B1hy9BsfLLwab19wODR2UWhnRmc

现在,出于某种原因,每当我想运行程序时,我一直得到未找到架构x86_64 的符号,我检查了编译输出 qt创作者及其所说的内容:

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讨论线程中寻找答案,但我无法找到任何相关内容。这样看起来似乎(或许我只是看起来很难看)

干杯们,非常感谢提前

1 个答案:

答案 0 :(得分:0)

您正在将您的析构函数声明为Vehicle类virtual ~Vehicle(),但您没有为其提供实现。如果您不想释放任何内容,则应将其声明为virtual ~Vehicle() {}。这同样适用于MotorVehicle析构函数。

未找到&#34;符号&#34;错误是非常误导的。实际上,它说有一个定义的符号,主要是函数,没有找到实现。

相关问题