Note that there are some explanatory texts on larger screens.

plurals
  1. POQt Q_OBJECT creates linker errors in Visual Studio 2010
    text
    copied!<p>I'm trying to get Qt to work with Visual Studio 2010. I've built a working program that I can run in the debugger. However, when I try to add the Q_OBJECT macro to my class, it generates a bunch of linker errors.</p> <pre><code>1&gt;------ Build started: Project: qt_poop, Configuration: Debug Win32 ------ 1&gt;Build started 2012/08/05 12:58:56. 1&gt;InitializeBuildStatus: 1&gt; Creating "Debug\qt_poop.unsuccessfulbuild" because "AlwaysCreate" was specified. 1&gt;ClCompile: 1&gt; GLViewer.cpp 1&gt; Window.cpp 1&gt; main.cpp 1&gt; Generating Code... 1&gt;Link: 1&gt; LINK : c:\Users\abral\Documents\Visual Studio 2010\Projects\qt_poop\Win32\Debug\\qt_poop.exe not found or not built by the last incremental link; performing full link 1&gt;GLViewer.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GLViewer::metaObject(void)const " (?metaObject@GLViewer@@UBEPBUQMetaObject@@XZ) 1&gt;GLViewer.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall GLViewer::qt_metacast(char const *)" (?qt_metacast@GLViewer@@UAEPAXPBD@Z) 1&gt;GLViewer.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GLViewer::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@GLViewer@@UAEHW4Call@QMetaObject@@HPAPAX@Z) 1&gt;c:\Users\abral\Documents\Visual Studio 2010\Projects\qt_poop\Win32\Debug\\qt_poop.exe : fatal error LNK1120: 3 unresolved externals 1&gt; 1&gt;Build FAILED. 1&gt; 1&gt;Time Elapsed 00:00:07.50 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== </code></pre> <p>I've seen some similar problems raised by others and it seems to have something to do with the compiler and moc and a bunch of other really complicated technical stuff that my beginner brain can't quite comprehend yet. Also, a lot of it seems geared towards people who are using a command line to configure their compilers, but I'm using VS and I'd really like to keep it that way (basically I just want to be able to press the green arrow and see my program - that's all). So... if someone could explain to me in as simple a way as possible how to configure Visual Studio to do whatever linking or compiling or whatnot that it needs to do to accomplish this, I'll be eternally grateful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload