public: static struct QMetaObject const QsciScintillaBase::staticMetaObject



  • public: static struct QMetaObject const QsciScintillaBase::staticMetaObject

    hello I want to use QsciScintilla to make le editor
    if I use Q_OBJECT ,it will make error lnk 2001 . if I remove Q_OBJECT ,it will build success。
    the build tool is VS 2010 ,I had set the Configuration Manager release。 HOW CAN I DO IT

    #include <Qsci/qsciscintillabase.h>
    class DIY_QsciScintilla:public QsciScintilla
    {
    Q_OBJECT
    public:
    DIY_QsciScintilla(QWidget *parent = 0);
    ~DIY_QsciScintilla();
    };



  • waiting!!!!!!!!!!!!!!!!!!!!!!!


  • Moderators

    You should post the whole error message not just part of it.
    Most probably you did not run qmake and a complete rebuild of your project after adding Q_OBJECT macro.
    So, add Q_OBJECT, execute qmake and then rebuild your project (you can even delete the build directory before you do the rebuild if you're using shadow build).

    And there is no need for so many exclamation marks.



  • @jsulm 14:56:09: 为项目PHPC执行步骤 ...
    14:56:09: 正在启动 "H:\CoderTools\QTcreator\bin\jom.exe" clean

    H:\CoderTools\QTcreator\bin\jom.exe -f Makefile.Release clean
    del release\moc_phpc.cpp release\moc_diy_qsciscintilla.cpp
    del ui_phpc.h
    del release\main.obj release\phpc.obj release\diy_qsciscintilla.obj release\moc_phpc.obj release\moc_diy_qsciscintilla.obj
    del release\PHPC.intermediate.manifest release\PHPC.exp
    H:\CoderTools\QTcreator\bin\jom.exe -f Makefile.Debug clean
    

    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\debug\moc_phpc.cpp
    del debug\moc_phpc.cpp debug\moc_diy_qsciscintilla.cpp
    del ui_phpc.h
    del debug\main.obj debug\phpc.obj debug\diy_qsciscintilla.obj debug\moc_phpc.obj debug\moc_diy_qsciscintilla.obj
    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\ui_phpc.h
    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\debug\main.obj
    del debug\PHPC.intermediate.manifest debug\PHPC.exp debug\PHPC.ilk vc*.pdb vc*.idb
    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\debug\PHPC.intermediate.manifest
    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\vc*.pdb
    del ".\PHPC.intermediate.manifest"
    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\PHPC.intermediate.manifest
    del PHPC.exp
    找不到 H:\code\QT\QT\build-PHPC-unknown-Release\PHPC.exp
    14:56:09: 进程"H:\CoderTools\QTcreator\bin\jom.exe"正常退出。
    14:56:09: 配置没有改变, 跳过 qmake 步骤。
    14:56:09: 正在启动 "H:\CoderTools\QTcreator\bin\jom.exe"

    H:\CoderTools\QTcreator\bin\jom.exe -f Makefile.Release
    h:\CoderTools\QT\bin\uic.exe ..\PHPC\phpc.ui -o ui_phpc.h
    cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"..\..\..\..\CoderTools\QT\include\QtCore" -I"..\..\..\..\CoderTools\QT\include\QtGui" -I"..\..\..\..\CoderTools\QT\include" -I"..\..\..\..\CoderTools\QT\include" -I"..\..\..\..\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"..\..\..\..\CoderTools\QT\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\xavier\AppData\Local\Temp\main.obj.63308.15.jom
    

    main.cpp
    H:\CoderTools\QT\bin\moc.exe -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"........\CoderTools\QT\include\QtCore" -I"........\CoderTools\QT\include\QtGui" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"........\CoderTools\QT\mkspecs\win32-msvc2010" -D_MSC_VER=1600 -DWIN32 ..\PHPC\phpc.h -o release\moc_phpc.cpp
    H:\CoderTools\QT\bin\moc.exe -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"........\CoderTools\QT\include\QtCore" -I"........\CoderTools\QT\include\QtGui" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"........\CoderTools\QT\mkspecs\win32-msvc2010" -D_MSC_VER=1600 -DWIN32 ..\PHPC\diy_qsciscintilla.h -o release\moc_diy_qsciscintilla.cpp
    cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"........\CoderTools\QT\include\QtCore" -I"........\CoderTools\QT\include\QtGui" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"........\CoderTools\QT\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\xavier\AppData\Local\Temp\moc_phpc.obj.63308.171.jom
    moc_phpc.cpp
    cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"........\CoderTools\QT\include\QtCore" -I"........\CoderTools\QT\include\QtGui" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"........\CoderTools\QT\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\xavier\AppData\Local\Temp\diy_qsciscintilla.obj.63308.31.jom
    diy_qsciscintilla.cpp
    cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"........\CoderTools\QT\include\QtCore" -I"........\CoderTools\QT\include\QtGui" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"........\CoderTools\QT\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\xavier\AppData\Local\Temp\phpc.obj.63308.140.jom
    phpc.cpp
    ..\PHPC\phpc.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
    cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DNDEBUG -I"........\CoderTools\QT\include\QtCore" -I"........\CoderTools\QT\include\QtGui" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include" -I"........\CoderTools\QT\include\ActiveQt" -I"release" -I"." -I"..\PHPC" -I"." -I"........\CoderTools\QT\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\xavier\AppData\Local\Temp\moc_diy_qsciscintilla.obj.63308.515.jom
    moc_diy_qsciscintilla.cpp
    ..\PHPC\phpc.cpp(19) : warning C4482: 使用了非标准扩展: 限定名中使用了枚举“QsciScintilla::BraceMatch”
    link /LIBPATH:"h:\CoderTools\QT\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /MANIFEST /MANIFESTFILE:"release\PHPC.intermediate.manifest" /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /OUT:release\PHPC.exe @C:\Users\xavier\AppData\Local\Temp\PHPC.exe.63308.1046.jom
    moc_diy_qsciscintilla.obj : error LNK2001: 无法解析的外部符号 "public: static struct QMetaObject const QsciScintilla::staticMetaObject" (?staticMetaObject@QsciScintilla@@2UQMetaObject@@B)
    release\PHPC.exe : fatal error LNK1120: 1 个无法解析的外部命令
    jom: H:\code\QT\QT\build-PHPC-unknown-Release\Makefile.Release [release\PHPC.exe] Error 1120
    jom: H:\code\QT\QT\build-PHPC-unknown-Release\Makefile [release] Error 2
    14:56:10: 进程"H:\CoderTools\QTcreator\bin\jom.exe"退出,退出代码 2 。
    Error while building/deploying project PHPC (kit: 桌面)
    When executing step "Make"
    14:56:10: Elapsed time: 00:01.


  • Moderators

    So, you do not use qmake. Do you include the moc_*.cpp files in *.cpp files?


  • Moderators

    @xavieryang007
    as already mentioned rerun qmake (on your .pro file) to rebuild the makefiles. So the moc files also get built into your binaries. Then the linker error should be gone.

    Note: When using Visual Studio IDE the same is achieved automatically by the Qt plugin.



  • I had already rebuild the makefiles.but It still has the same error in the project



  • @raven-worx I had already rebuild the makefiles.but It still has the same error in the project!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.