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. Defining preprocessor macros in pro file
QtWS25 Last Chance

Defining preprocessor macros in pro file

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 9.0k Views
  • 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.
  • S Offline
    S Offline
    syrianzoro
    wrote on last edited by
    #1

    hi everyone,

    I defined many macros in pro file each of them in project file , (I am trying to implement Qt Assistant topic creating shared libs)

    @ #include <QtCore/QtGlobal>

    #if defined(MYSHAREDLIB_LIBRARY)

    define MYSHAREDLIB_EXPORT Q_DECL_EXPORT

    #else

    define MYSHAREDLIB_EXPORT Q_DECL_IMPORT

    #endif@

    one of them always defines Q_DECL_IMPORT instead Q_DECL_EXPORT , I spent alot of time tracking the code, syntax, but in vain.

    Qt is the future

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luisvaldes88
      wrote on last edited by
      #2

      Hi.

      I don't if this help, but anyway.

      In your .pro file you will have

      MySharedLib.pro

      @DEFINES += MYSHAREDLIB_LIBRARY@

      this means that when you are compiling your program, whenever the compiler reads
      @MYSHAREDLIB_EXPORT@
      it will replace with
      @Q_DECL_EXPORT@

      and when you run your applicacion,
      @MYSHAREDLIB_LIBRARY@
      is not defined, so it will replace
      @MYSHAREDLIB_EXPORT@
      with
      @Q_DECL_IMPORT@

      sorry if it was not your doubt. i did not understand you question anyway.
      :D

      Muchos quieren, pocos pueden, algunos consiguen.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        syrianzoro
        wrote on last edited by
        #3

        thank you luisvaldes88 for reply

        but the proposed way that macros are intended to work is:

        in the same project
        @MYSHAREDLIB_EXPORT@
        should be @Q_DECL_EXPORT@

        out side the project
        should be @Q_DECL_IMPORT@

        I think it is qmake issue because of the dependencies between the libs , I noticed that the calling libs (which use the base) built first although the base lib qmaked first

        Qt is the future

        1 Reply Last reply
        0

        • Login

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