Results 1 to 3 of 3

Thread: inconsitent dll linkage, MetaObject: definition of dllimport static member not allowe

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question inconsitent dll linkage, MetaObject: definition of dllimport static member not allowe

    Using MSVC2013, Qt 5.3.2: I have compiled succesfully a lib Mylib.lib, Mylib.dll. Im trying to link it with my MyApp. however while
    compiling my MyApp(with MSVC2013) I'm failing with "inconsitent dll linkage, MetaObject: definition of dllimport static member not allowed"

    My library has:

    1) Mylibraryglobal.h

    #if defined(FLAGLIB_EXPORT)
    # define FLAGLIB_EXPORT Q_DECL_EXPORT
    #else
    # define FLAGLIB_EXPORT Q_DECL_IMPORT
    #endif

    2) pro file of the library:
    TEMPLATE = lib

    3) MyLibclass.cpp:

    class FLAGLIB_EXPORT MyClass : public QObject
    {

    }

    MyApp is accessing all the header files of MyLib and using MyLib classes.

    what should be the content of my MyApp project file in order to properly link to the library?

    Thanks;

    Mut

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: inconsitent dll linkage, MetaObject: definition of dllimport static member not al

    I think your Mylibraryglobal.h does not make sense. If you don't define FLAGLIB_EXPORT in your pro file you will get an import macro, if you do define it, you will get a compiler error about trying to redefine an existing macro. The if statement should operate on a different macro than the one that is used for the export/import.
    Last edited by wysota; 10th October 2014 at 09:57. Reason: Fixed stupid dictionary spelling correction
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: inconsitent dll linkage, MetaObject: definition of dllimport static member not al

    right, an export header usually looks like this

    Qt Code:
    1. #ifndef MYLIB_EXPORT_H
    2. #define MYLIB_EXPORT_H
    3.  
    4. #include <qglobal.h>
    5.  
    6. #ifndef MYLIB_EXPORT
    7. # if defined(MAKE_MYLIB)
    8. /* We are building this library */
    9. # define MYLIB_EXPORT Q_DECL_EXPORT
    10. # else
    11. /* We are using this library */
    12. # define MYLIB_EXPORT Q_DECL_IMPORT
    13. # endif
    14. #endif
    15.  
    16.  
    17. #endif // MYLIB_EXPORT_H
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 20th October 2011, 15:14
  2. Static linkage of the library
    By Sergei Smirnov in forum Qt Programming
    Replies: 0
    Last Post: 22nd June 2010, 18:17
  3. Replies: 17
    Last Post: 26th January 2010, 20:21
  4. Replies: 22
    Last Post: 8th October 2008, 13:54
  5. Replies: 3
    Last Post: 19th February 2008, 13:10

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.