Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Shared Library: Import and export simultaneously ?
Forum Update on Tuesday, May 27th 2025

Shared Library: Import and export simultaneously ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    huckfinn
    wrote on 10 Nov 2011, 12:12 last edited by
    #1

    Hello ,
    I have a solution which contains of several projects

    !http://img705.imageshack.us/img705/1500/sharedn.png(Architecture)!

    as you can see.
    There is the main project which includes the main.exe.
    Then I have a few shared.dll libraries, which have several functionalities.
    Furtheron, I plan to separate common used functions into other shared dll's (util.dll's), see third layer.

    • Q_DECL_EXPORT must be added to the declarations of symbols used when compiling a shared library.
    • Q_DECL_IMPORT must be added to the declarations of symbols used when compiling a client that uses the shared library.

    Since my shared.dll's should be compiled as a shared library, so I have set the macro Q_DECL_EXPORT
    Furtheron, my shared.dll's are compiled as a client that uses the shared library (util.dll), so I have to set the Q_DECL_IMPORT macro?

    Any suggestions? Are there any suitable possibilities..?

    Cheers Huck

    [EDIT: fixed image link, Volker]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on 10 Nov 2011, 12:43 last edited by
      #2

      In your dll project file define something like this:
      @
      #define YOUR_LIBRARY
      @

      then in dll public header, define something like this:
      @
      #if defined(YOUR_LIBRARY)

      define YOUR_PUBLIC_DEFINE Q_DECL_EXPORT

      #else

      define YOUR_PUBLIC_DEFINE Q_DECL_IMPORT

      #endif
      @

      Then every class, function or varibale that you want to be exported, must pe preceded by YOUR_PUBLIC_DEFINE

      For example:
      @
      YOUR_PUBLIC_DEFINE yourClass{ ... }
      YOUR_PUBLIC_DEFINE void yourFunnction() {...}
      @

      [edit] I wanted to say project preprocessor defines, and not define YOUR_LIBRARY in header file
      So if you use qmake, in project file write
      @
      DEFINES += YOUR_LIBRARY
      @
      In VC, goto in project settings, C++ -> Preprocessor -> Preprocessor definitions

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on 10 Nov 2011, 12:58 last edited by
        #3

        See http://doc.qt.nokia.com/stable/sharedlibrary.html for hints.

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0

        1/3

        10 Nov 2011, 12:12

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved