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. Qt Project - application depending on a DLL file
Forum Updated to NodeBB v4.3 + New Features

Qt Project - application depending on a DLL file

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 5.2k 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.
  • raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #2

    copy the generated dll into the same directory were you start the exe, or add the path to the dll to the PATH environment variable.

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • I Offline
      I Offline
      it4chi
      wrote on last edited by
      #3

      Hi, and thank you for you reply,

      i have already found this solution, but the main drawback is that there is a dependancy between both project i have mentionned. Indeed, if for example there is happening a modification or an update in the DLL project, the "project 2" has to know it and adapt the new generated dll file "automatically".
      So copy paste the dll into exe directory is not the solution. I think one of the best solution is to set to the INCLUDEPATH the path which leads to the DLL.
      That is what i did :
      INCLUDEPATH += $$PWD/../project1/release/myDLL.dll
      But that does not work... Problem is i don't understand all tools in the .pro file, i have just started programming with Qt Creator this morning :/
      Sorry if i look like stupid

      1 Reply Last reply
      0
      • I Offline
        I Offline
        it4chi
        wrote on last edited by
        #4

        any help ? :(

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #5

          you do not need to include the DLL file into your project! the DLL file is the result and the compiler doesn't need know anything about the DLL file.

          Instead the file which is interesting for the compiler are the *.a (mostly mingw32, gcc,...) and *.lib (MSVC, sometimes also unix, ...) files.

          You are also NOT using the INCLUDEPATH variable correct in your project file!
          Your pro-File should look like this:
          @
          INCLUDEPATH += ../testLib //path to the header files
          LIBS+= -L../myDLL/debug -lmyDLL //path to the .a/.lib files
          @

          The compiler mostly is able to look for the correct file extension, thus it should be sufficient to just supply -lmyDLL.

          You said you have an error starting the exe which couldn't find the DLL, so copying the DLL to the exe is part of the distribution which is necessary to run the program.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • I Offline
            I Offline
            it4chi
            wrote on last edited by
            #6

            mmm Okay...
            Indeed, when i put the DLL file into exe directory i don't have any error, that's run alright.

            Thanks for explaining me differences between DLL and *a/*lib files, that is very useful !
            I think i will just copy the DLL directly by a C++ function from project1 to project2,

            My problem is solved, thanks again for wasting your time for a begginer like me ;)

            Cheers !

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #7

              for this purpose you would be better off using QMAKE_POST_LINK, which will be executed after the build process has finished.

              E.g. for windows:
              @
              win32:QMAKE_POST_LINK = copy <source-path>\*.dll <target-path>
              @

              or alternatively call a bat file (shell script) which does everything you need after building finished.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • I Offline
                I Offline
                it4chi
                wrote on last edited by
                #8

                that is the Qt command i have written in order to copy my DLL into my directory

                @win32:QMAKE_POST_LINK = copy /Y $$PWD/../libDeclarativeScriptParser/release/libDeclarativeScriptParser.dll $$PWD/release@

                But this does not work :/ it is strange, i have found many examples about it, and all used this command. But when i use it i don't have my DLL in my target directory :/

                What if i used a "copy" function in my program ?

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #9

                  did you rerun qmake after you did add this line inorder to update the makefiles accordingly?

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    it4chi
                    wrote on last edited by
                    #10

                    Sorry for my later reply

                    here is my command line :
                    @win32:QMAKE_POST_LINK = $${QMAKE_COPY} ../libDeclarativeScriptParser/release/libDeclarativeScriptParser.dll release/@

                    When i run my qmake, there is showing an error

                    @The process "C:\QtSDK\mingw\bin\mingw32-make.exe" has been terminated - error code : 2@

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

                      Hi,

                      You have to give a more complete error log, this one doesn't say much

                      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
                      • I Offline
                        I Offline
                        it4chi
                        wrote on last edited by
                        #12

                        here are my errors

                        @mingw32-make: *** [release] Error 2
                        The process "C:\QtSDK\mingw\bin\mingw32-make.exe" has been terminated - error code : 2
                        step "Make" execution error@

                        but i have no more logs :/
                        I don't have any error when i build the application without this "copy" command line

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

                          Are you sure the paths are correct ?

                          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
                          • I Offline
                            I Offline
                            it4chi
                            wrote on last edited by
                            #14

                            i think so, that is my path :

                            @Parent Directory
                            ------>libDeclarativeScriptParser (Project 1)
                            -----> Release
                            -------> libDeclarativeScriptParser.dll
                            ------->Project 2
                            ------> Release@

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

                              When executing the copy, you might not be in the directory you think. Try to make something like:
                              @cd@

                              in place of your current copy command to see where you are

                              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

                              • Login

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