DLLDESTDIR variables in qmake (DLLDESTDIR and TARGET_EXT) not defined



  • I have a .pro file for a library in which I want to build the path of the DLL/so (the target).

    The TARGET variable contains the name of the target without the extension, but I can get around that by defining the extension with scopes. I thought TARGET_EXT would contain the extension, but it is empty.

    According to the documentation DLLDESTDIR "Specifies where to copy the target dll." Since the DLL/so is created in the build-PROJECT-Debug\debug folder I thought that I would be able to get this path from the variable, however it is also empty.

    Is there some variable that contains the target folder?


  • Lifetime Qt Champion

    Hi,

    Something's not clear here, why do you want to modify the libraries extension ? Also which extension are you talking about ?

    The correct file extension is set automagically for you by qmake



  • Where did I say I wanted to change the extension? How many extensions does the target have, only one that I'm aware of?

    As you mentioned, the extension is set by qmake, I want to get the value, but as I clearly indicated in my post, that it isn't my major concern. I want to get to the target folder, which according to what I've been able to determine from the documentation should be defined in DLLDESTDIR, which is empty.


  • Lifetime Qt Champion

    Some people consider the library numbering on Linux like an extension.

    DLLDESTDIR is a variable that you set if you want to copy the target dll (it windows only)

    Can you tell what you would like to achieve, it might be easier then to help you



  • I need to copy the DLL to other locations in the build tree. I just need to get the target folder to be able to do the copy of the target file (mylib.dll) from that folder. It worked on Linux, but now I'm having issues on Windows (using MinGW). The .pro file was using $(TARGET0) as well which is not defined on Windows.


  • Lifetime Qt Champion

    Copying the DLL in multiple places in the same build tree sounds like there's something wrong. You should rather link to it from the other places



  • If you want your DLL to be created in a specific folder under your building tree, set that directory in DESTDIR. The documentation is not clear but I suppose this variable is meant to hold a relative path under your current build tree (so absolute paths might feel uncomfortable to qmake).
    If you need to retrieve the DLL file for linking or whatever reason, remember that OUT_PWD gives you the absolute full path were qmake generates the main makefile. If you didn't change the makefile directory, then this path is going to be the same as the root of your build directory. So now, you can travel from here to whatever subdirectory you want.

    for instance, I am using DESTDIR = dll to build a dll file in a subfolder (so the DLL is output to something like: "my_project_build_dir/dll/mydllfile.dll"). I am also using OUT_PWD to retrieve an absolute path to the compiled DLL path, so I can retrieve the .a file necessary for linking and compiling an exe (I am using it like this: LIBS += -L$$OUT_PWD/dll -lmydllfile)

    Can you tell us why do you need to copy the DLL to other locations? I agree with SGaist in that it sounds like a bad idea. maybe, by just using DESTDIR you can output it directly where you need it, without creating more chaos with multiple copies everywhere.

    p.s. DLLDESTDIR and TARGET_EXT are not defined until qmake is actually starting the building process. At the point of evaluating the .pro file these variables are empty - unless you define some value in each.



  • As stated in my original post I just want to retrieve the target folder to be able to copy the target file to another location. This is known during the build process as this is where the target file is placed. All I'm asking is if it is possible in some way to query what that folder is going to be. Surely that is not such a difficult question. It doesn't really matter why I want it, I just want to know if I can get it.

    I eventually just hard coded the folder by defining it as:
    @DESTDIR=$${OUT_PWD}/$${FOLDER}@

    with FOLDER defined as release or debug depending on the type of build.

    I'm begining to dread posting on this forum!



  • If you want to know which folder will be used by default for the building process, then this setting is accessible in QtCreator's options. From the menubar go to: Tools> options > Build & Run and have a look at the Default build directory setting. The default one is "../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}". Additionally debug and release folders are created inside the build folder such that you have:
    (some_path_before)/build/debug and (some_path_before)/build/release. This is where your files are usually built.

    As I said previously, the OUT_PWD (unless you explicitly modify it - which seems you don't) is going to tell you the exact main folder of the build: (some_path_before)/build so you can travel from this folder to any subfolder you have.
    Also, please read the whole thing I have written: if you set a particular path in DESTDIR (or DLLDESTDIR) then your build is going to put your files inside THAT path. Which means, if you set:
    DLLDESTDIR = dll_release
    your dll is going to be output in:
    (some_path_before)/build/dll_release
    and you can retrieve this exact path by using $$OUT_PWD/$$DLLDESTDIR. This is exactly what you're looking for.
    (if you don't set any value in DLLDESTDIR or DESTDIR all the files built will go under the debug or release folders: $$OUT_PWD/debug or $$OUT_PWD/release )


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.