PDA

View Full Version : Linking errors LNK2019 external symbol in release mode



stepchik
7th June 2011, 14:47
Hi. When i try to build release version i get linking errors LNK2019 external symbol
Something like:



qt4client.obj : error LNK2019: unresolved external symbol "public: static struct QMetaObject const TelEngine::QtWindow::staticMetaObject" (?staticMetaObject@QtWindow@TelEngine@@2UQMetaObje ct@@B) referenced in function "public: static class QString __cdecl TelEngine::QtWindow::tr(char const *,char const *)" (?tr@QtWindow@TelEngine@@SA?AVQString@@PBD0@Z)

But debug mode works fine. Please explain what i forgot?

VS2008, QT4.6

joyer83
7th June 2011, 22:01
Hmm, maybe the moc file generation rules have gone out of sync...
Try updating them, by first removing one letter from the Q_OBJECT macro (e.g. Q_OBJEC) and then save the header file. Now the mocing rules should have been automatically removed. Then fix the macro and save again, now the rules should have been added automatically.
Then try compiling again.

Santosh Reddy
8th June 2011, 00:29
looks like namespace is not being included in release mode.

function "tr(char const *,char const *)" is being searched in namespace "TelEngine", Are you sure tr() exists in "TelEngine" namespace

stepchik
8th June 2011, 08:58
Hmm, maybe the moc file generation rules have gone out of sync...
Try updating them, by first removing one letter from the Q_OBJECT macro (e.g. Q_OBJEC) and then save the header file. Now the mocing rules should have been automatically removed. Then fix the macro and save again, now the rules should have been added automatically.
Then try compiling again.

Thanks for your answer. I try to compile - nothing.


looks like namespace is not being included in release mode.

function "tr(char const *,char const *)" is being searched in namespace "TelEngine", Are you sure tr() exists in "TelEngine" namespace


Thanks for your answer. Hm how can it be that in debug mode some function is part of namespace but in release this function is't?
Look like you are right. I have some LNK2019 message "anonymous namespace" in another project


customtext.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void * __thiscall TelEngine::QtCustomWidget::qt_metacast(char const *)" (__imp_?qt_metacast@QtCustomWidget@TelEngine@@UAEP AXPBD@Z) referenced in function "public: virtual void * __thiscall `anonymous namespace'::CustomTextEdit::qt_metacast(char const *)" (?qt_metacast@CustomTextEdit@?A0x2fb7e806@@UAEPAXP BD@Z)
customtext.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual int __thiscall TelEngine::QtCustomWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (__imp_?qt_metacall@QtCustomWidget@TelEngine@@UAEH W4Call@QMetaObject@@HPAPAX@Z) referenced in function "public: virtual int __thiscall `anonymous namespace'::CustomTextEdit::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@CustomTextEdit@?A0x2fb7e806@@UAEHW4C all@QMetaObject@@HPAPAX@Z)
customtext.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const TelEngine::QtCustomWidget::staticMetaObject" (__imp_?staticMetaObject@QtCustomWidget@TelEngine@ @2UQMetaObject@@B) referenced in function "void __cdecl `dynamic initializer for 'public: static struct QMetaObject const `anonymous namespace'::CustomTextEdit::staticMetaObject''(voi d)" (??__E?staticMetaObject@CustomTextEdit@?A0x2fb7e80 6@@2UQMetaObject@@B@@YAXXZ)

Santosh Reddy
8th June 2011, 15:09
There were a couple of questions running accros my mind, might sound strange.

What is "TelEngine" (in your project), I assume it is a namespae, is this namespace tope level, or a is it inside some other namespace? Which don't think is.

How do you related (mean how do you use) with Qt namespace? are they independent, or dependant on each other?

If you use multiple namesapces, is there any multiple inheritance from object from two different namespaces? Which is simply possible.

Also if "TelEngine" is from external library, then make sure the library is build in release mode too.

stepchik
9th June 2011, 11:22
"TelEngine" is namespace top level. My solution has another project(without QT) which links to QT project with LNK errors. External library builds in release mode without problem. Both projects has namespace "TelEngine".

Qt project and external linking module has one namespace - "TelEngine"