Important: Please read the Qt Code of Conduct -

File .obj not found on Windows

  • Hi, I wanted to add some new functions to my program I created with free Qt version using my registered one. I use another Windows computer now and it looks like installation of Qt was OK because I can run demo examples. But for some reason although I can see missing files on debug folder I get errors (23 !)
    like this "unresolved external symbol_xxx File not found xxx.obj" I know that I didn't have those errors when I finished the project for 2 years ago! Where can be the problem? I'm not using Qt on Windows on normal case , mostly on Linux, now I have no idea what to do. The function have to be added and delivered to customer 15 August. Any help will be appreciated.

  • Lifetime Qt Champion

    @Norrbotten Can you provide the whole build log?

  • Lifetime Qt Champion

    Also, please delete any .user file in the project folder and re setup the project with the kits.

  • hi, I already did it and nothing happens. I found that the only part of the code with class (C++ class) added to project gives the problem. Project was done on the older version of QT, maybe now is it different way to add classes to the project?
    I created a new a new empty project and just added a C++ class (base class QObject with included Q Widget).
    And it will not work
    #ifndef SOMECLASS_H
    #define SOMECLASS_H

    #include <QObject>
    #include <QWidget>

    class someClass : public QObject
    explicit someClass(QObject *parent = nullptr);


    public slots:
    void DoSomething();

    #endif // SOMECLASS_H


    #include "someclass.h"
    #include <QMessageBox>

    someClass::someClass(QObject *parent) : QObject(parent)


    void someClass::DoSomething()
    QMessageBox msg;


    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "someclass.h"
    someClass *myClass;
    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)
    myClass=new someClass(this);

    delete ui;
    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl someClass::someClass(class QObject *)" (??0someClass@@QEAA@PEAVQObject@@@Z) referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)

    debug\TestObjErrors.exe:-1: error: LNK1120: 1 unresolved externals

  • Hi @Norrbotten

    You use explicit with your someClass contructor which means you have to explicitly cast QWidget * (the thisin myClass=new someClass(this);) to QObject * in MainWindow::MainWindow.


  • @m.sue I used this way for few years ago . The software working fin (executable I created at that time) no such problems as I have now I had at that time
    #ifndef GLWIDGET_H
    #define GLWIDGET_H

    #include <QGLWidget>

    class GLWidget : public QGLWidget
    *explicit GLWidget(QWidget parent = 0);

    public slots:
    void RePaint();
    void initializeGL() ;
    void paintGL() ;
    void resizeGL(int w, int h);

    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);


    #endif // GLWIDGET_H
    Must probably the syntactic was changed while I didn't use Qt . How otherwise have I declare the class?

  • Lifetime Qt Champion

    @Norrbotten Can you please post the whole build log?

  • Lifetime Qt Champion

    @m.sue explicit only tells the compiler to not to use the constructor for implicit type conversions like:

    QObject* obj;
    someClass sClass = obj; // Without explicit compiler would use someClass(QObject *parent = nullptr) constructor to convert QObject* to someClass, with explicit this line will cause a compiler error

  • Hi, in case some one have the same problem.
    I receive help from support.
    in .h have to be

    #include <QtGui/QOpenGLFunctions_1_1>
    class bscanclass : public QGLWidget, QOpenGLFunctions_1_1
    explicit bscanclass(QWidget *parent = 0);

    call from main:
    bscanclass *BscanW; // declaration

    and then
    BscanW=new bscanclass(this);

    Working perfect now. Thank you very much for trying to help

Log in to reply