QT错误:LNK1120:1未解决的外部Main.OBJ:-1:错误:LNK2019运行QMAKE



我无法弄清楚为什么会遇到错误:main.obj:-1:错误:lnk2019:未解决的外部符号"公共:__ thiscall standbywindow :: standbywindow(void)"(?? 0standbywindow @@ qae@qae@qae@xz)在函数_main中引用和debug pointer_test.exe:-1:错误:lnk1120:1未解决的外部

main.cpp

  #include <QCoreApplication>
  #include <QDebug>
  #include "standby.h"
  Standbywindow *standby_window;
  int main(int argc, char *argv[])
  {
  QCoreApplication a(argc, argv);
     standby_window = new Standbywindow;
  return a.exec();
  }

standby.h

 #ifndef STANDBY_H
 #define STANDBY_H
 #include <QDebug>
 class Standbywindow{
 public:
 Standbywindow();
 };
 #endif // STANDBY_H

standby.cpp

#include "standby.h"
Standbywindow::Standbywindow(){
}

pointer_test.pro

  #-------------------------------------------------
  #
  # Project created by QtCreator 2015-05-10T11:08:06
  #
  #-------------------------------------------------
  QT       += core
  QT       -= gui
  TARGET = pointer_test
  CONFIG   += console
  CONFIG   -= app_bundle
  TEMPLATE = app

  SOURCES += main.cpp 
     standby.cpp
  HEADERS += 
     standby.h

编译输出

09:08:23: Running steps for project pointer_test...
09:08:23: Configuration unchanged, skipping qmake step.
09:08:23: Starting: "C:QtToolsQtCreatorbinjom.exe" 
C:QtToolsQtCreatorbinjom.exe -f Makefile.Debug  
cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc        /Fddebugpointer_test.pdb -DUNICODE -DWIN32 -DQT_CORE_LIB -I"..pointer_test" -         I"."  -I"C:Qt5.4msvc2010_openglinclude" -I"C:Qt5.4msvc2010_openglincludeQtCore" -I"debug" -I"C:Qt5.4msvc2010_openglmkspecswin32-msvc2010" -Fodebug @C:UsersMikeAppDataLocalTempmain.obj.10328.16.jom
   main.cpp
   echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "debug\pointer_test.exe.embed.manifest">debugpointer_test.exe_manifest.rc
   if not exist debugpointer_test.exe if exist   debugpointer_test.exe.embed.manifest del debugpointer_test.exe.embed.manifest
     if exist debugpointer_test.exe.embed.manifest copy /Y debugpointer_test.exe.embed.manifest debugpointer_test.exe_manifest.bak
     link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32'      name='Microsoft.Windows.Common-Controls' version='6.0.0.0'      publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debugpointer_test.exe.embed.manifest /OUT:debugpointer_test.exe @C:UsersMikeAppDataLocalTemppointer_test.exe.10328.2250.jom
    main.obj : error LNK2019: unresolved external symbol "public: __thiscall Standbywindow::Standbywindow(void)" (??0Standbywindow@@QAE@XZ) referenced in      function _main
    debugpointer_test.exe : fatal error LNK1120: 1 unresolved externals
     jom: C:UsersMikeDocumentsQTbuild-pointer_test-  Desktop_Qt_5_4_1_MSVC2010_OpenGL_32bit-DebugMakefile.Debug [debugpointer_test.exe] Error 1120
   jom: C:UsersMikeDocumentsQTbuild-pointer_test-  Desktop_Qt_5_4_1_MSVC2010_OpenGL_32bit-DebugMakefile [debug] Error 2
 09:08:26: The process "C:QtToolsQtCreatorbinjom.exe" exited with code 2.
 Error while building/deploying project pointer_test (kit: Desktop Qt 5.4.1 MSVC2010 OpenGL 32bit)
 When executing step "Make"
 09:08:26: Elapsed time: 00:03.

确保standby.cpp在.pro文件中列为源文件,然后尝试再次运行qmake(构建 -> run qmake),然后尝试构建。您也可以尝试清洁/重建项目。

最新更新