Results 1 to 6 of 6

Thread: Linking errors LNK2019 external symbol in release mode

  1. #1
    Join Date
    Apr 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Linking errors LNK2019 external symbol in release mode

    Hi. When i try to build release version i get linking errors LNK2019 external symbol
    Something like:


    Qt Code:
    1. qt4client.obj : error LNK2019: unresolved external symbol "public: static struct QMetaObject const TelEngine::QtWindow::staticMetaObject" (?staticMetaObject@QtWindow@TelEngine@@2UQMetaObject@@B) referenced in function "public: static class QString __cdecl TelEngine::QtWindow::tr(char const *,char const *)" (?tr@QtWindow@TelEngine@@SA?AVQString@@PBD0@Z)
    To copy to clipboard, switch view to plain text mode 

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

    VS2008, QT4.6

  2. #2
    Join Date
    Aug 2008
    Posts
    45
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linking errors LNK2019 external symbol in release mode

    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.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Linking errors LNK2019 external symbol in release mode

    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

  4. The following user says thank you to Santosh Reddy for this useful post:

    stepchik (8th June 2011)

  5. #4
    Join Date
    Apr 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Linking errors LNK2019 external symbol in release mode

    Quote Originally Posted by joyer83 View Post
    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.

    Quote Originally Posted by Santosh Reddy View Post
    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

    Qt Code:
    1. customtext.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void * __thiscall TelEngine::QtCustomWidget::qt_metacast(char const *)" (__imp_?qt_metacast@QtCustomWidget@TelEngine@@UAEPAXPBD@Z) referenced in function "public: virtual void * __thiscall `anonymous namespace'::CustomTextEdit::qt_metacast(char const *)" (?qt_metacast@CustomTextEdit@?A0x2fb7e806@@UAEPAXPBD@Z)
    2. 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@@UAEHW4Call@QMetaObject@@HPAPAX@Z) referenced in function "public: virtual int __thiscall `anonymous namespace'::CustomTextEdit::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@CustomTextEdit@?A0x2fb7e806@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
    3. 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''(void)" (??__E?staticMetaObject@CustomTextEdit@?A0x2fb7e806@@2UQMetaObject@@B@@YAXXZ)
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Linking errors LNK2019 external symbol in release mode

    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.

  7. #6
    Join Date
    Apr 2011
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Linking errors LNK2019 external symbol in release mode

    "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"

Similar Threads

  1. Help - LNK2019: Unresolved external symbol
    By marc2050 in forum Newbie
    Replies: 3
    Last Post: 17th May 2011, 02:29
  2. Replies: 3
    Last Post: 29th April 2011, 10:13
  3. Replies: 2
    Last Post: 11th February 2011, 15:44
  4. Replies: 4
    Last Post: 5th January 2011, 16:51
  5. Replies: 1
    Last Post: 10th April 2009, 19:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.