Qt:在架构x86_64找不到的符号
Qt: symbol(s) for not found for architecture x86_64
我是Qt的新手,只是一般的编程新手,我在为我正在制作的游戏添加分数时遇到了一些问题。我有一个分数类、障碍类和一个游戏类等,我正在尝试连接当前用于生成障碍物的 QTimer 来更新分数,以便分数每 2500 毫秒上升 1 个。请帮忙!
这是我的分数头文件:
#include <QGraphicsTextItem>
#include <QObject>
class score : public QGraphicsTextItem {
Q_OBJECT
public:
//constructor
score(QGraphicsItem * parent=0);
//other functions
int get_score();
int score_value;
public slots:
void increase_score();
};
#endif // SCORE
这是分数源文件:
//i'm including QFont, QString, QObject, and QDebug
#include "score.h"
#include "obstacle.h"
score::score(QGraphicsItem *parent) : QGraphicsTextItem(parent){
//initialize score to zero
score_value = 0;
//draw the text
setPlainText(QString("Score: ") + QString::number(score_value));
setDefaultTextColor(Qt::white);
setFont(QFont("arial",25));
}
void score::increase_score(){
score_value++;
qDebug() << "score has increased";
setPlainText(QString("Score: ") + QString::number(score_value));
}
int score::get_score() {
return score_value;
}
这是我的游戏类源文件的相关部分,它创建了整个游戏:
#include "game.h"
#include "score.h"
#include "main_menu.h"
#include "game_over.h"
#include <QObject>
#include <QImage>
#include <QBrush>
#include <QTimer>
game::game(QWidget *parent) {
...
//create the score
Score = new score();
scene->addItem(Score);
//spawn obstacles
QTimer * timer = new QTimer();
QObject::connect(timer, SIGNAL(timeout()), copter, SLOT(spawn()));
timer->start(2500);
//connect score to timer
connect(timer, SIGNAL(timeout()), Score, SLOT(increase_score()));
}
现在我收到错误说
找不到建筑x86_64符号
链接器命令失败,退出代码为 1
我正在尝试使用信号和插槽,以便分数更新,而不仅仅是坐在零......但我不知道如何解决此错误。感谢您的帮助!
信号和时隙机制依赖于名为MOC的Qt工具生成的额外源代码。您需要在 score.h 上运行 MOC,并在项目中编译生成的C++源。缺少的符号将位于 MOC C++代码中。
如果你使用 qmake 生成你的项目文件,它会为你完成所有这些工作,但是在你添加带有信号/插槽的新类后,你需要再次运行 qmake。
相关文章:
- CMake 生成的 MSVC 项目找不到符号,即使为其相关 dll 正确生成了 lib 文件也是如此
- 错误:当我从"WinDbg"打开可执行文件时,找不到符号文件。默认导出 ntdll 的符号.dll
- 编译 GCC-5.0 OS X 狮子 dyld:找不到符号:__ZNKSt11logic_error4whatEv
- 在 Mac 上C++编译代码时处理“dyld:惰性符号绑定失败:找不到符号”错误
- 与 dlopen 的动态链接:找不到符号
- MacOS LD:找不到符号(x86_64)
- dyld:惰性符号绑定失败:找不到符号:_yylex
- OSX MOJAVE -LD:架构X86_64 clang找不到符号:错误:链接器命令失败,出口代码1
- LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See
- GCC LD:构造I386找不到符号
- dyld:惰性符号绑定失败:找不到符号.预期在:平面命名空间
- 链接库时找不到符号
- sql::mysql::get_driver_instance()找不到符号
- 在我的嵌套 for 循环中找不到符号"k"?
- 惰性符号绑定失败:找不到符号
- 链接器链接正确的文件,但找不到符号
- 链接器读取库,但在其中找不到符号?未解析的外部符号,但仅适用于 Win32 而不是 x64
- Ctypes 在使用 CMake 创建的共享库中找不到符号
- G++ LD:在体系结构x86_64找不到符号
- ShiftVector 模板类 - "找不到符号"