Results 1 to 11 of 11

Thread: DLL Linking Error with a Plugin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    98
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default DLL Linking Error with a Plugin

    Alright, bear with me; here's the compiler output: (I added newlines to make it easier to read)
    1>Link:
    1> Creating library C:\Users\eulmer\Desktop\Qt Replication\testBB\Win32\Release\testBB.lib and object C:\Users\eulmer\Desktop\Qt Replication\testBB\Win32\Release\testBB.exp

    1>moc_testbb.obj : error LNK2019: unresolved external symbol
    "public: static struct QMetaObject const BERTSpinbox::staticMetaObject" (?staticMetaObject@BERTSpinbox@@2UQMetaObject@@B)
    referenced in function
    "public: static class QString __cdecl BERTSpinbox::tr(char const *,char const *)" (?tr@BERTSpinbox@@SA?AVQString@@PBD0@Z)

    1>main.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const BERTSpinbox::staticMetaObject" (?staticMetaObject@BERTSpinbox@@2UQMetaObject@@B)

    1>testbb.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const BERTSpinbox::staticMetaObject" (?staticMetaObject@BERTSpinbox@@2UQMetaObject@@B)

    1>C:\Users\eulmer\Desktop\Qt Replication\testBB\Win32\Release\\testBB.exe : fatal error LNK1120: 1 unresolved externals
    1>
    1>Build FAILED.
    here's the undecorated names from the dll (that are relevant)(in order)(using dependency walker):
    struct QMetaObject const BERTSpinbox::staticMetaObject
    class QString BERTSpinbox::tr(char const *,char const *)
    I know I never defined these; but why would I have to?* What am I missing here? What is this darn thing trying to tell me to add? Other plugins (referring to the other thread) worked just fine using the same algorithm for building them (so to speak.)

    Researching lead me to believe this has something to do with wchars but I checked the relevant settings in the project file (that i never messed with in the first place mind you) and they are all good. Any thoughts?


    *I say that because the only function I called from the DLL was the standard constructor with a QWidget parameter

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Linking Error with a Plugin

    Have you put Q_OBJECT in the class def?

    Have you correctly linked with the plugin?

    Have you correctly exported the class into the dll?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jun 2012
    Posts
    98
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: DLL Linking Error with a Plugin

    Yes
    Yes (another plugin using the same folders and such works just fine with no issues.)
    Yes (as can be seen by using the dependency walker on it and examining the functions it contains) (also, I corrected it as per the other thread)

    EDIT:
    After some digging it turns out (I never realized) that declaring Q_OBJECT happens to include a boatload of functions; this function that has no definition is one of those functions. Is this just a random bug that I'll have to work around? Maybe building a new class with the same functionality would work..?
    Last edited by tescrin; 2nd August 2012 at 00:02.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Linking Error with a Plugin

    What happens if you find the moc file for the plugin and add the dllexport modifier?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Jun 2012
    Posts
    98
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: DLL Linking Error with a Plugin

    Same error . I will say that in surveying the moc file I didn't see a function by said name, though it is defined *somewhere* (as I attempted to implement it as a way to test the problem.)

    This will sound dumb, but I think I'm going to redo that project really quick and see if it's just some odd project setting I did or... something. I'm out of ideas. If it works I'll just assume I messed with an option I wasn't supposed to (or blame qt :P )

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Linking Error with a Plugin

    maybe you can zip up your project/some example and post it here. Otherwise it's pretty hard for anyone else to diagnose.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7
    Join Date
    Jun 2012
    Posts
    98
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: DLL Linking Error with a Plugin

    I've gone ahead and built an example. It should have all the path/library locations/dependencies set up for you (at least if we had the same macros.)

    It does show the same errors (though I didn't check if the mangled names were identical; I assume they are since it's the same code :s.) Thanks for any help!


    EDIT: Yeah, it's the code. Just attempted to reuse the code in a fresh qt-designer-plugin project and it's doing the same thing (which.. is to be expected; but still a bit sad.)
    Attached Files Attached Files
    Last edited by tescrin; 2nd August 2012 at 17:21.

Similar Threads

  1. Replies: 1
    Last Post: 2nd December 2011, 08:36
  2. Linking Error
    By amitpatel22 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 28th June 2011, 12:40
  3. Replies: 4
    Last Post: 22nd May 2011, 13:36
  4. Static linking problem with gif plugin, qt 4.6.2, vs 2008
    By colin207 in forum Qt Programming
    Replies: 3
    Last Post: 25th June 2010, 14:39
  5. Qt Creator Just one linking error
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 2
    Last Post: 16th August 2009, 13:00

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.