[SOLVED]Unresolved External Error - Why???
-
Hi Folks!
I have the following code for a Widget:
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include "globaldef.h"
#include "ccamera.h"class GLWidget : public QGLWidget
{
public:
GLWidget(QWidget *parent);
~GLWidget();
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void timerEvent(QTimerEvent *) { update(); }
void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }void Render();
public slots:
private:
int timerId;
CCamera pCam;};
#endif // GLWIDGET_HAnd i create a simple Class(without derive from any class from Qt) and with just a constructor like this:
#ifndef CCAMERA_H
#define CCAMERA_Hclass CCamera
{
public:
CCamera();
};#endif // CCAMERA_H
Why , when i comple the code i receive the following error?
glwidget.obj : error LNK2019: unresolved external symbol "public: __cdecl CCamera::CCamera(void)" (??0CCamera@@QEAA@XZ) referenced in function "public: __cdecl GLWidget::GLWidget(class QWidget *)" (??0GLWidget@@QEAA@PEAVQWidget@@@Z)
debug\INS2.exe : fatal error LNK1120: 1 unresolved externalsAnyone here can help me?
Kind Regards
-
Hi!
Just for instance...i just compile the code removing the constructor of the class(renaming it to other method), than works....Why this happen?
How can we work with constructors in Qt, becouse some classes i will need work have a lot of initializations, like Scene Management templates and etc...,It will be hard implement the BSP tree without this becouse i need make copy of my objects every time...
Kind Regards.
-
Hi,
Please enclose your code in coding tags to make it readable (you can just edit your original post)
Did you implement the CCamera constructor ?
-
Hi SGaist,
In fact i discover what´s happening...with your help in other post.
I just dont realize we need run qMake before Rebuild our changes.
When this changes was updated by the tool the code run as expected.Thanks so much for your help.
Kind Regards. -
You're welcome !
Re-running qmake is not always needed, it depends on the changes you made.
Since it's all good now, don't forget to update the thread's title to solved so other forum users may know a solution has been found :)
-
When changing something with Designer or some other issue related to QObjects etc, it is a good idea (when strange unexplainable issues appear) to rebuild with qmake.
Place [SOLVED] on the first post, it will stop us from reading this post to try to help.