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. macOS: "export DYLD_IMAGE_SUFFIX=_debug" in qmake (".pro") file?
Forum Updated to NodeBB v4.3 + New Features

macOS: "export DYLD_IMAGE_SUFFIX=_debug" in qmake (".pro") file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 6 Posters 1.7k Views 4 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.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    According to this article, I should ensure that that var is defined in my "environment variables" for my debug version.

    Is there a way i can set that in my .pro file instead of in the "Run Settings->Environment" table?

    kshegunovK 1 Reply Last reply
    0
    • D davecotter

      According to this article, I should ensure that that var is defined in my "environment variables" for my debug version.

      Is there a way i can set that in my .pro file instead of in the "Run Settings->Environment" table?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Not natively, at least I don't think so. But you could try setting it through a system( ... ) call, I think it should work.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • jeremy_kJ Offline
        jeremy_kJ Offline
        jeremy_k
        wrote on last edited by
        #3

        Is this in reference to running an application through Creator?

        Qmake seems unlikely to help. It's a build tool. Unless running the application is set up as a build target, qmake is uninvolved.

        The execution environment is written to the .pro.user file for qmake projects. You could either modify that, or try a shared settings file.

        Asking a question about code? http://eel.is/iso-c++/testcase/

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #4

          @kshegunov not sure what you mean. i'm running the app through Qt Creator, i just press the "run" button, so there's no opportunity to call "system" BEFORE my app is started.

          @jeremy_k yes, running through Qt Creator. Seems that "shared settings" may be "thee only whaay", i'll try that.

          kshegunovK 1 Reply Last reply
          0
          • D davecotter

            @kshegunov not sure what you mean. i'm running the app through Qt Creator, i just press the "run" button, so there's no opportunity to call "system" BEFORE my app is started.

            @jeremy_k yes, running through Qt Creator. Seems that "shared settings" may be "thee only whaay", i'll try that.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @davecotter said in macOS: "export DYLD_IMAGE_SUFFIX=_debug" in qmake (".pro") file?:

            @kshegunov not sure what you mean. i'm running the app through Qt Creator, i just press the "run" button, so there's no opportunity to call "system" BEFORE my app is started.

            The build phase involves actually calling qmake, so invoking the shell and exporting the variable from the invocation of the qmake "should" work.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davecotter
              wrote on last edited by davecotter
              #6

              @jeremy_k i investigated this approach and i don't understand how this can work. I'm trying to avoid having separate "run configurations" for debug and release, inside Qt Creator, so the only thing that is different is the "Build Configuration" (between debug and release). In this screen shot you'll see i have only one Deploy and one Run config, that all of my Build configs use:

              Screen Shot 2021-05-30 at 9.06.20 AM.png

              Yet still i wish to programmatically set the environment var for debug only, when the app is run from Creator.

              @kshegunov I am not following what you're saying. Can you be more explicit with a how-to step? How do i "invoke the shell ... from the invocation of qmake" ?

              Do you mean it should be an "Additional Argument" in the qmake build step?

              Screen Shot 2021-05-30 at 9.12.47 AM.png

              if so, what would be the syntax?

              -dave

              kshegunovK 1 Reply Last reply
              0
              • D davecotter

                @jeremy_k i investigated this approach and i don't understand how this can work. I'm trying to avoid having separate "run configurations" for debug and release, inside Qt Creator, so the only thing that is different is the "Build Configuration" (between debug and release). In this screen shot you'll see i have only one Deploy and one Run config, that all of my Build configs use:

                Screen Shot 2021-05-30 at 9.06.20 AM.png

                Yet still i wish to programmatically set the environment var for debug only, when the app is run from Creator.

                @kshegunov I am not following what you're saying. Can you be more explicit with a how-to step? How do i "invoke the shell ... from the invocation of qmake" ?

                Do you mean it should be an "Additional Argument" in the qmake build step?

                Screen Shot 2021-05-30 at 9.12.47 AM.png

                if so, what would be the syntax?

                -dave

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @davecotter said in macOS: "export DYLD_IMAGE_SUFFIX=_debug" in qmake (".pro") file?:

                Do you mean it should be an "Additional Argument" in the qmake build step?

                No I meant for you to put it in the project file, something along the lines of:

                CONFIG(debug, debug|release): system("export DYLD....=_debug");
                

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  davecotter
                  wrote on last edited by
                  #8

                  @kshegunov oh very interesting. are you sure that that environ var is guaranteed to persist for the actual run of the app, like in the same shell? i'm concerned that the shell instance run during qmake time and the shell instance run to actually open the app may be different instances?

                  kshegunovK 1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi,

                    I think there might be some misunderstanding here. This variable shall be set at run time so there's nothing in qmake that will allow you to do that.

                    qmake is a project manager nothing more.

                    You will have to set this variable in each debug build variant you have.

                    You might be able to that more quickly editing the .pro.user file using a text editor. Do not forget to make a copy before modifying it.

                    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
                    • D davecotter

                      @kshegunov oh very interesting. are you sure that that environ var is guaranteed to persist for the actual run of the app, like in the same shell? i'm concerned that the shell instance run during qmake time and the shell instance run to actually open the app may be different instances?

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by kshegunov
                      #10

                      @davecotter said in macOS: "export DYLD_IMAGE_SUFFIX=_debug" in qmake (".pro") file?:

                      @kshegunov oh very interesting. are you sure that that environ var is guaranteed to persist for the actual run of the app, like in the same shell? i'm concerned that the shell instance run during qmake time and the shell instance run to actually open the app may be different instances?

                      Yes, you're right, I didn't think of that x_x ... and @SGaist confirms I'm dead wrong.

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        davecotter
                        wrote on last edited by
                        #11

                        You will have to set this variable in each debug build variant

                        yeah that's exactly what i'm trying to avoid. I want just ONE "run config" that all my "build configs" use, not one for debug and one for release.

                        I guess there isn't a way to do this :(

                        JonBJ 1 Reply Last reply
                        0
                        • D davecotter

                          You will have to set this variable in each debug build variant

                          yeah that's exactly what i'm trying to avoid. I want just ONE "run config" that all my "build configs" use, not one for debug and one for release.

                          I guess there isn't a way to do this :(

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #12

                          @davecotter
                          I know nothing about MacOS. Just how early does this DYLD_IMAGE_SUFFIX environment variable need to be set? Is it used prior to loading and running the executable by the OS loader or something, or is it used at runtime once/after your application code starts executing?

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            davecotter
                            wrote on last edited by
                            #13

                            how early does this DYLD_IMAGE_SUFFIX environment variable need to be set?

                            I don't know, i was just following the advice of this article. I want debug so i can step through the Qt frameworks.

                            JonBJ 1 Reply Last reply
                            0
                            • D davecotter

                              how early does this DYLD_IMAGE_SUFFIX environment variable need to be set?

                              I don't know, i was just following the advice of this article. I want debug so i can step through the Qt frameworks.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by JonB
                              #14

                              @davecotter
                              I know, I saw, but it doesn't say anything about when that environment variable gets used. If it's only once your code gets executed, I was thinking you could have runtime code to set the environment variable suitably in debug build only. A different approach if it works for you.

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                Before running your application.

                                That's an environment variable in the same category as LD_LIBRARY_PATH.

                                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
                                1
                                • jeremy_kJ Offline
                                  jeremy_kJ Offline
                                  jeremy_k
                                  wrote on last edited by
                                  #16

                                  It's used when looking up the library name to load, Eg libQt5Core${suffix}.dylib. For non-programmatically loaded libraries, this is effectively when the application process starts executing.

                                  I think it's also used for dlopen(), but I don't know if the value is cached the first time it is accessed, or if updates to the environment variable can be made during the lifetime of the process.

                                  Asking a question about code? http://eel.is/iso-c++/testcase/

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    davecotter
                                    wrote on last edited by
                                    #17

                                    so, reading deeper, it occurred to me that perhaps this is about building Qt Libraries? I'm not doing that, i'm running my own app, based on existing Qt Libraries... so am i just just thinking too hard? Is it the case that i don't need this at all?

                                    I see that without specifying this in my Run Config, i'm able to debug into Qt Libraries just fine....

                                    ?

                                    jeremy_kJ 1 Reply Last reply
                                    0
                                    • JoeCFDJ Offline
                                      JoeCFDJ Offline
                                      JoeCFD
                                      wrote on last edited by JoeCFD
                                      #18

                                      qputenv(const char *varName, const QByteArray &value) will do it as well in your code in case something else is needed to be set.
                                      varName and value can be set from command line arguments on QtCreator run.

                                      1 Reply Last reply
                                      0
                                      • D davecotter

                                        so, reading deeper, it occurred to me that perhaps this is about building Qt Libraries? I'm not doing that, i'm running my own app, based on existing Qt Libraries... so am i just just thinking too hard? Is it the case that i don't need this at all?

                                        I see that without specifying this in my Run Config, i'm able to debug into Qt Libraries just fine....

                                        ?

                                        jeremy_kJ Offline
                                        jeremy_kJ Offline
                                        jeremy_k
                                        wrote on last edited by
                                        #19

                                        @davecotter said in macOS: "export DYLD_IMAGE_SUFFIX=_debug" in qmake (".pro") file?:

                                        so, reading deeper, it occurred to me that perhaps this is about building Qt Libraries?

                                        DYLD_IMAGE_SUFFIX changes runtime library loading. It's not a build time thing.
                                        man 1 dyld should help clarify, and lists other variables that can be useful.

                                        I see that without specifying this in my Run Config, i'm able to debug into Qt Libraries just fine....

                                        In the macOS copy of Qt 5.15.2 I'm looking at, there's a clang_64/lib/QtCore.framework/
                                        that contains the shared library, and a clang_64/lib/QtCore.framework.dSYM/ with dwarf debug symbols and a python helper for lldb. It looks like this is Apple's version of pdb style separate debugging symbols. man dsymutil has some information.

                                        $ file QtCore.framework/QtCore 
                                        QtCore.framework/QtCore: Mach-O 64-bit dynamically linked shared library x86_64
                                        $ file QtCore.framework.dSYM/Contents/Resources/DWARF/QtCore 
                                        QtCore.framework.dSYM/Contents/Resources/DWARF/QtCore: Mach-O 64-bit dSYM companion file x86_64
                                        

                                        Asking a question about code? http://eel.is/iso-c++/testcase/

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          davecotter
                                          wrote on last edited by
                                          #20

                                          sorry but can you spell out your conclusion? does that mean that i do NOT need to set this env var at all?

                                          jeremy_kJ 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