Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Unresolved External Error - Why???
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Unresolved External Error - Why???

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wwolff
    wrote on last edited by
    #1

    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_H

    And i create a simple Class(without derive from any class from Qt) and with just a constructor like this:
    #ifndef CCAMERA_H
    #define CCAMERA_H

    class 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 externals

    Anyone here can help me?

    Kind Regards

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wwolff
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wwolff
        wrote on last edited by
        #3

        Again, i start work with the class , and when i use any member of the Camera class , the error starts again...how can i use this class inside a Widget class???

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wwolff
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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 :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • JeroentjehomeJ Offline
                JeroentjehomeJ Offline
                Jeroentjehome
                wrote on last edited by
                #7

                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.

                Greetz, Jeroen

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved