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. QtCreator fails to run an application that depends on a library in the same project
Forum Updated to NodeBB v4.3 + New Features

QtCreator fails to run an application that depends on a library in the same project

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

    Hi,

    I am using QtCreator 4.1.0 from revision 8c80a86266 on Windows with Visual Studio 2015

    My project is as follows:

    TestProject.qbs

    Project
    {
        references:
        [
            "TestApp/TestApp.qbs",               
            "TestLib/TestLib.qbs"
        ]
    }
    

    TestApp.qbs

    CppApplication
    {
        Depends { name: "TestLib" }              
    
        files: [
            "main.cpp",
        ]
    }
    

    main.cpp

    __declspec(dllimport) int test_returner ();  
    
    int main ()
    {
        return test_returner ();
    }
    

    TestLib.qbs

    DynamicLibrary
    {
        Depends { name: "cpp" }                  
    
        files: [
            "dllmain.cpp",
        ]
    }
    

    dllmain.cpp

    __declspec(dllexport) int test_returner ()   
    {
        return 123;
    }
    

    The problem is, if run with QtCreator the program crashes before even starting, which is fixed by copying TestLib.dll over to the directory that contains TestApp.exe.

    I would always do it this way ( Depends { name: LIBNAME } ) on my linux machine without any problems but I'm forced to windows for a while and I'm not sure if its a bug or if I have to do some additional/different stuff in my qbs files, hence my question: How do I fix it ?

    Thought about utilizing qbs' destinationDirectory property by setting it to sourceDirectory + "/../bin" to fix the separate directory problem for exe and dll, but then I'm being trolled as it creates the folder dotdot/bin/ in sourceDirectory.

    raven-worxR 1 Reply Last reply
    0
    • S slyp

      Hi,

      I am using QtCreator 4.1.0 from revision 8c80a86266 on Windows with Visual Studio 2015

      My project is as follows:

      TestProject.qbs

      Project
      {
          references:
          [
              "TestApp/TestApp.qbs",               
              "TestLib/TestLib.qbs"
          ]
      }
      

      TestApp.qbs

      CppApplication
      {
          Depends { name: "TestLib" }              
      
          files: [
              "main.cpp",
          ]
      }
      

      main.cpp

      __declspec(dllimport) int test_returner ();  
      
      int main ()
      {
          return test_returner ();
      }
      

      TestLib.qbs

      DynamicLibrary
      {
          Depends { name: "cpp" }                  
      
          files: [
              "dllmain.cpp",
          ]
      }
      

      dllmain.cpp

      __declspec(dllexport) int test_returner ()   
      {
          return 123;
      }
      

      The problem is, if run with QtCreator the program crashes before even starting, which is fixed by copying TestLib.dll over to the directory that contains TestApp.exe.

      I would always do it this way ( Depends { name: LIBNAME } ) on my linux machine without any problems but I'm forced to windows for a while and I'm not sure if its a bug or if I have to do some additional/different stuff in my qbs files, hence my question: How do I fix it ?

      Thought about utilizing qbs' destinationDirectory property by setting it to sourceDirectory + "/../bin" to fix the separate directory problem for exe and dll, but then I'm being trolled as it creates the folder dotdot/bin/ in sourceDirectory.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @slyp said in QtCreator fails to run an application that depends on a library in the same project:

      I would always do it this way ( Depends { name: LIBNAME } ) on my linux machine without any problems but I'm forced to windows for a while and I'm not sure if its a bug or if I have to do some additional/different stuff in my qbs files, hence my question: How do I fix it ?

      yes, maybe a bug.
      Can you pls post the generated makefile?

      --- 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

      S 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @slyp said in QtCreator fails to run an application that depends on a library in the same project:

        I would always do it this way ( Depends { name: LIBNAME } ) on my linux machine without any problems but I'm forced to windows for a while and I'm not sure if its a bug or if I have to do some additional/different stuff in my qbs files, hence my question: How do I fix it ?

        yes, maybe a bug.
        Can you pls post the generated makefile?

        S Offline
        S Offline
        slyp
        wrote on last edited by
        #3

        @raven-worx said in QtCreator fails to run an application that depends on a library in the same project:

        Can you pls post the generated makefile?

        Can't find one

        Andy@Andy-PC /cygdrive/d/Dev/TestProject/build-TestProject-Desktop_Qt_5_7_0_MSVC2015_32bit-Debug
        $ find . -print
        .
        ./qtc_Desktop__a1af886e-debug/qtc_Desktop__a1af886e-debug.bg
        ./qtc_Desktop__a1af886e-debug/qtc_Desktop__a1af886e-debug.bg.lock
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/.obj
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/.obj/3a52ce780950d4d9/main.cpp.obj
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/.obj/vc140.pdb
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/intermediate.TestApp.exe
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/intermediate.TestApp.exe.manifest
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/intermediate.TestApp.ilk
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/TestApp.exe
        ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/TestApp.pdb
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/.obj
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/.obj/3a52ce780950d4d9/dllmain.cpp.obj   
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/.obj/vc140.pdb
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.dll
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.exp
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.ilk
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.lib
        ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.pdb
        

        Isn't qbs supposed to not rely on makefiles anymore ?

        raven-worxR 1 Reply Last reply
        0
        • S slyp

          @raven-worx said in QtCreator fails to run an application that depends on a library in the same project:

          Can you pls post the generated makefile?

          Can't find one

          Andy@Andy-PC /cygdrive/d/Dev/TestProject/build-TestProject-Desktop_Qt_5_7_0_MSVC2015_32bit-Debug
          $ find . -print
          .
          ./qtc_Desktop__a1af886e-debug/qtc_Desktop__a1af886e-debug.bg
          ./qtc_Desktop__a1af886e-debug/qtc_Desktop__a1af886e-debug.bg.lock
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/.obj
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/.obj/3a52ce780950d4d9/main.cpp.obj
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/.obj/vc140.pdb
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/intermediate.TestApp.exe
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/intermediate.TestApp.exe.manifest
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/intermediate.TestApp.ilk
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/TestApp.exe
          ./qtc_Desktop__a1af886e-debug/TestApp.qtc-Desktop--a1af886e.73fd51ec/TestApp.pdb
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/.obj
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/.obj/3a52ce780950d4d9/dllmain.cpp.obj   
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/.obj/vc140.pdb
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.dll
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.exp
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.ilk
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.lib
          ./qtc_Desktop__a1af886e-debug/TestLib.qtc-Desktop--a1af886e.2ecbf469/TestLib.pdb
          

          Isn't qbs supposed to not rely on makefiles anymore ?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @slyp
          sorry, wasn't really up-to-date with QBS.
          QBS doesn't create makefiles of course.

          --- 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
          1

          • Login

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