“未找到架构x86_64的符号”在QtCreator项目 [英] "Symbol(s) not found for architecture x86_64" on QtCreator project

查看:546
本文介绍了“未找到架构x86_64的符号”在QtCreator项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误

Symbol(s) not found for architecture x86_64

尝试在QtCreator上编译项目。它发生在我尝试创建一个用户定义类 Layer 的实例。该类由一个头文件 layer.h 和一个实现 layer.cpp 组成。它被测试和工作在另一个程序。在我的项目中,它包含在 qtwidget.h 中,并且当我尝试在 qtwidget.cpp 。例如:

Trying to compile a project on QtCreator. It happens when I try to create an instance of an user defined class, Layer. That class consists of a header, layer.h, and a implementation, layer.cpp. It was tested and works in another programs. On my project, it is included in qtwidget.h and the error happens when I try to use it on qtwidget.cpp. For example:

Layer<double> text("pq.txt",0.5,0.5,0.5);

qtwidget.cpp 足够的错误显示。

这是一个通用的错误,我无法如何隔离任何进一步,但如果它有帮助,我包括整个项目这个git仓库

This is such a generic error that I'm clueless on how to isolate it any further, but if it helps, I've included the whole project on this git repo.

推荐答案

在我看来,Qt Creator显示的错误消息是非常误导的,直到你明白它,但不阻止将模板类拆分为头文件和实现文件。如果您考虑到以下消息:

In my opinion, the error message that Qt Creator displays is quite misleading until you understand it, but does not prevent splitting the template class into a header and implementation file. If you think about the message:

Symbol(s) not found for architecture x86_64

这个问题,我原以为当我看到这个,是它自己在问题输出并且可以引导用户认为问题是由于架构造成的。

the problem, I originally thought when I saw this, is that it states this error on its own in the Issues output and can lead the user into thinking that the problem is due to the architecture. Actually, all its saying is that there's a defined symbol (often function) whose matching implementation wasn't found.

如果你从问题改变了,到编译输出窗口并向上滚动,您将能够看到无法找到什么符号;我的红色显示。

If you change from Issues to the Compile Output window and scroll up, you'll be able to see exactly what symbols can't be found; mine's displayed in red. It's just annoying that the detail of the missing symbol(s) doesn't show up in the Issues view.

这是很容易复制这个缺失的符号的细节没有出现在

It's easy to replicate this error by just adding a function definition into a header and without implementing the function, call it from the .cpp file. You'll then see something like this in the Issues window

切换到编译输出视图并向上滚动显示: -

Switching to the Compile Output view and scrolling up displays this: -

img src =http://i.stack.imgur.com/xHpYU.pngalt =enter image description here>

现在我们看到实际的问题是,在名为PGGui的类中的函数DoSomeStuff正在从构造函数PGGui :: PGGui中调用,但是DoSomeStuff的主体丢失了,因为找不到它的符号。

So now we see that tthe actual problem is that the function DoSomeStuff in the class called PGGui is being called from the constructor PGGui::PGGui, but the body of DoSomeStuff is missing, as its symbol is not found.

这篇关于“未找到架构x86_64的符号”在QtCreator项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆