PDA

View Full Version : Visual C++ compiler - moc generation



leoalvesmachado
21st June 2010, 20:54
Hi everyone.

I'm using QT Creator and the microsoft compiler in a project. However, I'm getting now some compiler errors (linker) due to some classes (Q_OBJECT) that I've added. I believe it is happening because there are .mocs to be generated and I believe the compiler is not generating them. Here are the error messares:


HpQCarouselEnvelope.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Hp::Psg::HpQCarouselEnvelope::metaObject(void)cons t " (?metaObject@HpQCarouselEnvelope@Psg@Hp@@UBEPBUQMe taObject@@XZ)
HpQCarouselEnvelope.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall Hp::Psg::HpQCarouselEnvelope::qt_metacast(char const *)" (?qt_metacast@HpQCarouselEnvelope@Psg@Hp@@UAEPAXPB D@Z)
HpQCarouselEnvelope.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Hp::Psg::HpQCarouselEnvelope::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@HpQCarouselEnvelope@Psg@Hp@@UAEHW4Ca ll@QMetaObject@@HPAPAX@Z)

command failed with exit code 1120
jom 0.8.3 - empower your cores

command failed with exit code 2
The process "C:/Qt/qtcreator-1.3.85/bin/jom.exe" exited with code %2.
Error while building project Apollo (target: Desktop)
When executing build step 'Make'

Is there anyone here that could help me, maybe a link teaching me how to force moc generation...

squidge
21st June 2010, 21:59
Do you use the Qt VS addin? That normally handles all the MOC stuff for you.

Ginsengelf
22nd June 2010, 08:20
Hi, you can add the moc call manually:
right-click the header of you class -> Properties -> Custom Build Step; add your moc call. Don't forget to add the generated moc_<classname>.cpp to your project.

But sometimes it helps to remove the class from the project once and add it again, the VS Addin will add the necessary steps for you.

Ginsengelf

Random
25th July 2011, 14:01
I also want to the answer!Please help me!!!