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. Finding out which application is calling Lib in build tree
Forum Updated to NodeBB v4.3 + New Features

Finding out which application is calling Lib in build tree

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.7pro fileqmakesubproject
6 Posts 3 Posters 2.2k Views 2 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.
  • A Offline
    A Offline
    alizadeh91
    wrote on 30 Aug 2016, 04:00 last edited by alizadeh91
    #1

    Hi, I have a parent project with three sub-projects (2 apps and 1 lib) in build tree which looks like:

    Project
    ---Project.pro
    -------------App1
    ------------------App1.pro
    -------------App2
    ------------------App2.pro
    -------------Lib
    ------------------Lib.pro

    and the lib is used by both apps.
    I've inserted a "DEFINES" keyword in the App1.pro and App2.pro as compiler C preprocessor macros to be able to check which application is called the lib. But, I can't find a way to send the macro over the lib.

    So, How can I find which application is calling the Lib? (I want to disable/enable some features in the Lib based on the app)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 30 Aug 2016, 04:25 last edited by
      #2

      It sounds more like something you need to do at runtime and not compile time using DEFINES. Since your lib is built only once you cannot differentiate between different apps at compile time. Instead you can pass different parameters from these different apps to the lib, so the lib can adjust its behaviour.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 30 Aug 2016, 04:37
      -1
      • J jsulm
        30 Aug 2016, 04:25

        It sounds more like something you need to do at runtime and not compile time using DEFINES. Since your lib is built only once you cannot differentiate between different apps at compile time. Instead you can pass different parameters from these different apps to the lib, so the lib can adjust its behaviour.

        A Offline
        A Offline
        alizadeh91
        wrote on 30 Aug 2016, 04:37 last edited by alizadeh91
        #3

        @jsulm This is why I want to use "compiler C preprocessor macros". When I select an app from "run configuration", Is it possible somehow to use this selection in compile time?!

        J 1 Reply Last reply 30 Aug 2016, 04:45
        0
        • A alizadeh91
          30 Aug 2016, 04:37

          @jsulm This is why I want to use "compiler C preprocessor macros". When I select an app from "run configuration", Is it possible somehow to use this selection in compile time?!

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 30 Aug 2016, 04:45 last edited by
          #4

          @alizadeh91 Just to be sure: you want the lib to behave differently depending on which app is using it and you want to decide at compile time, right? In this case you will need to build the lib for each application. So, if you have two apps then you will have two binaries of your lib.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alizadeh91
            wrote on 30 Aug 2016, 04:49 last edited by
            #5

            Yes, But the lib is in the same build tree as apps. So, I think there exist such a way to do that. Also, I want to for example change some minor things in the lib. If I duplicate the lib, then, I will be faced with serious issues with duplicating those codes later.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 30 Aug 2016, 15:13 last edited by
              #6

              Hi,

              What are these "minor things" ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              2/6

              30 Aug 2016, 04:25

              topic:navigator.unread, 4
              • Login

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