0

here is my customized LCD class inherited from QLCDNumber.

myLCD.h :

#ifndef MYLCD_H
#define MYLCD_H

#include <QLCDNumber>

class MyLCD : public QLCDNumber
{
    Q_OBJECT

public:
    MyLCD(QWidget* parent=0);


};


#endif // MYLCD_H

myLCD.cpp :

#include "MyLCD.h"


MyLCD::MyLCD(QWidget* parent)
    :QLCDNumber(parent)
{}

Nothing more basic than that..

in my main.cpp file, i include "myLCD.h" and everything is working properly.

But when i try to instanciate a myLCD object :

MyLCD* lcd = new MyLCD;

I get the following issues :

  • *main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall MyLCD::MyLCD(class QWidget *)" (??0MyLCD@@QAE@PAVQWidget@@@Z) referenced in function _main*

  • debug\partie2.exe:-1: error: LNK1120: 1 unresolved externals

any idea what that could be ?


edit : I'm using QtCreator

edit 2) : This is the output of the compilation result

14:33:28: Running steps for project partie2...
14:33:28: Configuration unchanged, skipping qmake step.
14:33:28: Starting: "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" 
    C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
    echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "debug\\partie2.exe.embed.manifest">debug\partie2.exe_manifest.rc
    if not exist debug\partie2.exe del debug\partie2.exe.embed.manifest>NUL 2>&1
    if exist debug\partie2.exe.embed.manifest copy /Y debug\partie2.exe.embed.manifest debug\partie2.exe_manifest.bak
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\partie2.exe.embed.manifest /OUT:debug\partie2.exe @C:\Users\val\AppData\Local\Temp\partie2.exe.10692.62.jom
main.obj : error LNK2019: unresolved external symbol "public: __thiscall MyLCD::MyLCD(class QWidget *)" (??0MyLCD@@QAE@PAVQWidget@@@Z) referenced in function _main
debug\partie2.exe : fatal error LNK1120: 1 unresolved externals
jom: H:\Fac\L3\S6\IHM\practical\Qt\TP2\sources\partie2\partie2-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile.Debug [debug\partie2.exe] Error 1120
jom: H:\Fac\L3\S6\IHM\practical\Qt\TP2\sources\partie2\partie2-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile [debug] Error 2
14:33:29: The process "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project partie2 (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK))
When executing step 'Make'
vdegenne
  • 12,272
  • 14
  • 80
  • 106
  • Where is the `MyLCD` implementation located? In the `main.cpp` file? And, I suppose that it should be `new MyLCD;` (capital M), right? – Andreas Fester Feb 08 '13 at 13:23
  • Good edit :) How do you link? Command line, or through some IDE? How does the linker call look like? – Andreas Fester Feb 08 '13 at 13:28
  • Looks like maybe your myLCD.cpp file isn't making it into the build process? Do you see it list properly as a source file in QtCreator? If not, add it and rebuild. – Bret Kuhns Feb 08 '13 at 13:33
  • Did you forgot the Q_OBJECT macro and added that later? If so _run qmake_ and than build. – Zlatomir Feb 08 '13 at 13:41

1 Answers1

2

I answer my own question since the bug was not so logically answerable..

I finally removed my Debug folder.

When i built once more, the Debug folder was created back and no issues shown.

I don't really know what is the reason, since when should we deal with the filesystem in a reliable IDE?

vdegenne
  • 12,272
  • 14
  • 80
  • 106
  • 2
    Ugh, I've hit this so many times in QtCreator. A full rebuild doesn't even fix the problem, you literally have to delete the Debug/Release folder(s) to get everything linking properly. Visual Studio doesn't have this problem and it uses the same compiler... – Bret Kuhns Feb 08 '13 at 14:06
  • there is the command "run qmake" in QtCreator, i guess this fix the problem as well (?) I'm not used still with this compilation since i've always build-and-run all my applications before – vdegenne Feb 08 '13 at 19:35