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. static library. no such file or directory
Forum Updated to NodeBB v4.3 + New Features

static library. no such file or directory

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 7.3k 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #4

    Did you run qmake from creator?
    This is accomplished through "Build"->"Run qmake". There should be a small bar showing in the lower right corner of Qt creator. The bar turns to green when qmake has finished.
    In the "Compile Output" window you may see at least that it has been started and finished.
    If you have placed message statements in your .pro file the output of those messages may be seen there too.

    For your checking you can check the content of INCLUDEPATH for example.

    TEMPLATE = app
    TARGET =
    CONFIG += console
    
    # Input
    SOURCES += main.cpp
    INCLUDEPATH += ../staticLibrary
    LIBS += -L../staticLibrary/debug -lstaticLibrary
    message("INCLUDEPATH " $$INCLUDEPATH)
    message("LIBS " $$LIBS)
    

    Concerning your problem: do you have the file "c:\CPP\Test\Test\test.h" ?
    That is where you are looking for "test.h".

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    1
    • Z Offline
      Z Offline
      zicx
      wrote on last edited by zicx
      #5

      yes, I ran it from the build menu.

      my path is C:\CPP\Test\Test and the test.h is in there

      Below is the output when I run qmake and then run App. Now it says cannot find test.lib
      13:18:45: Running steps for project App...
      13:18:45: Starting: "C:\Qt\5.7\msvc2015_64\bin\qmake.exe" C:\CPP\Test\App\App.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug"
      Project MESSAGE: INCLUDEPATH ../test
      Project MESSAGE: LIBS -L../test/debug -ltest
      Project MESSAGE: INCLUDEPATH ../test
      Project MESSAGE: LIBS -L../test/debug -ltest
      Project MESSAGE: INCLUDEPATH ../test
      Project MESSAGE: LIBS -L../test/debug -ltest
      13:18:45: The process "C:\Qt\5.7\msvc2015_64\bin\qmake.exe" exited normally.
      13:18:45: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" qmake_all

      jom 1.1.0 - empower your cores

      13:18:45: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited normally.
      13:18:45: Elapsed time: 00:00.

      after run

      13:20:02: Running steps for project App...
      13:20:02: Configuration unchanged, skipping qmake step.
      13:20:02: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe"
      C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
      link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:debug\App.exe @C:\Users\CE\AppData\Local\Temp\App.exe.11204.16.jom
      LINK : fatal error LNK1104: cannot open file 'test.lib'
      jom: C:\CPP\Test\build-App-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\App.exe] Error 1104
      jom: C:\CPP\Test\build-App-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\Makefile [debug] Error 2
      13:20:02: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
      Error while building/deploying project App (kit: Desktop Qt 5.7.0 MSVC2015_64bit)
      When executing step "Make"
      13:20:02: Elapsed time: 00:00.

      I do have a Test.lib in
      C:\CPP\Test\build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug

      kshegunovK 1 Reply Last reply
      0
      • Z zicx

        yes, I ran it from the build menu.

        my path is C:\CPP\Test\Test and the test.h is in there

        Below is the output when I run qmake and then run App. Now it says cannot find test.lib
        13:18:45: Running steps for project App...
        13:18:45: Starting: "C:\Qt\5.7\msvc2015_64\bin\qmake.exe" C:\CPP\Test\App\App.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug"
        Project MESSAGE: INCLUDEPATH ../test
        Project MESSAGE: LIBS -L../test/debug -ltest
        Project MESSAGE: INCLUDEPATH ../test
        Project MESSAGE: LIBS -L../test/debug -ltest
        Project MESSAGE: INCLUDEPATH ../test
        Project MESSAGE: LIBS -L../test/debug -ltest
        13:18:45: The process "C:\Qt\5.7\msvc2015_64\bin\qmake.exe" exited normally.
        13:18:45: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" qmake_all

        jom 1.1.0 - empower your cores

        13:18:45: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited normally.
        13:18:45: Elapsed time: 00:00.

        after run

        13:20:02: Running steps for project App...
        13:20:02: Configuration unchanged, skipping qmake step.
        13:20:02: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe"
        C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
        link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:debug\App.exe @C:\Users\CE\AppData\Local\Temp\App.exe.11204.16.jom
        LINK : fatal error LNK1104: cannot open file 'test.lib'
        jom: C:\CPP\Test\build-App-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\App.exe] Error 1104
        jom: C:\CPP\Test\build-App-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\Makefile [debug] Error 2
        13:20:02: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
        Error while building/deploying project App (kit: Desktop Qt 5.7.0 MSVC2015_64bit)
        When executing step "Make"
        13:20:02: Elapsed time: 00:00.

        I do have a Test.lib in
        C:\CPP\Test\build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug

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

        @zicx said in static library. no such file or directory:

        LINK : fatal error LNK1104: cannot open file 'test.lib'

        Is different from

        C:\CPP\Test\App\main.cpp:3: error: C1083: Cannot open include file: 'test.h': No such file or directory

        So why do you say there's no change?
        Anyway, output your project's current directory:

        message("pwd: " $$PWD)
        

        and make sure the library is generated at the specified location - that is when you apply the relative path you've passed to the LIBS variable to the current directory (PWD). Also do give your target a name:

        TARGET = myapplication
        

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • Z Offline
          Z Offline
          zicx
          wrote on last edited by zicx
          #7

          I missed that change in error, initially

          So, I get this
          Project MESSAGE: pwd: C:/CPP/Test/App
          Project MESSAGE: INCLUDEPATH ../test
          Project MESSAGE: LIBS -L../test/debug -ltest
          Project MESSAGE: pwd: C:/CPP/Test/App

          my Links
          INCLUDEPATH += ../test
          LIBS += -L../test/debug -ltest

          go to C:/CPP/Test/

          and the library seems to get created in a completely different folder
          C:\CPP\Test\build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug

          I dont understand how that should be and how I can fix it

          target in my app.pro is App
          TARGET = App

          and in test.pro it is Test
          TARGET = Test

          I tried copying a version of the Test.lib file into C:/CPP/Test/Test and C:/CPP/Test/App but that also did not help

          I also tried to just add it automatically. That did the trick. Loos like it needed the built paths

          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/release/ -lTest
          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug/ -lTest
          else:unix: LIBS += -L$$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/ -lTest

          INCLUDEPATH += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug
          DEPENDPATH += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug

          win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/release/libTest.a
          else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug/libTest.a
          else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/release/Test.lib
          else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug/Test.lib
          else:unix: PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/libTest.a

          kshegunovK 1 Reply Last reply
          0
          • Z zicx

            I missed that change in error, initially

            So, I get this
            Project MESSAGE: pwd: C:/CPP/Test/App
            Project MESSAGE: INCLUDEPATH ../test
            Project MESSAGE: LIBS -L../test/debug -ltest
            Project MESSAGE: pwd: C:/CPP/Test/App

            my Links
            INCLUDEPATH += ../test
            LIBS += -L../test/debug -ltest

            go to C:/CPP/Test/

            and the library seems to get created in a completely different folder
            C:\CPP\Test\build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug

            I dont understand how that should be and how I can fix it

            target in my app.pro is App
            TARGET = App

            and in test.pro it is Test
            TARGET = Test

            I tried copying a version of the Test.lib file into C:/CPP/Test/Test and C:/CPP/Test/App but that also did not help

            I also tried to just add it automatically. That did the trick. Loos like it needed the built paths

            win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/release/ -lTest
            else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug/ -lTest
            else:unix: LIBS += -L$$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/ -lTest

            INCLUDEPATH += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug
            DEPENDPATH += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug

            win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/release/libTest.a
            else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug/libTest.a
            else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/release/Test.lib
            else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug/Test.lib
            else:unix: PRE_TARGETDEPS += $$PWD/../build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/libTest.a

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

            @zicx said in static library. no such file or directory:

            I dont understand how that should be and how I can fix it

            It should be how you configured it. I ordinarily use shadow building so everything is in one single directory, however there's no "right" way if that's what you're asking. One thing you could do is to reconfigure your library project so it gets built in C:/CPP/Test/test/debug instead of being built in C:/CPP/Test/build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug, or changing the library include paths (the -L switch of the LIBS variable) to match the directory in which the library is actually created. Both approaches should work flawlessly, so it's up to you.

            Kind regards.

            Read and abide by the Qt Code of Conduct

            Z 1 Reply Last reply
            0
            • kshegunovK kshegunov

              @zicx said in static library. no such file or directory:

              I dont understand how that should be and how I can fix it

              It should be how you configured it. I ordinarily use shadow building so everything is in one single directory, however there's no "right" way if that's what you're asking. One thing you could do is to reconfigure your library project so it gets built in C:/CPP/Test/test/debug instead of being built in C:/CPP/Test/build-Test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug/debug, or changing the library include paths (the -L switch of the LIBS variable) to match the directory in which the library is actually created. Both approaches should work flawlessly, so it's up to you.

              Kind regards.

              Z Offline
              Z Offline
              zicx
              wrote on last edited by
              #9

              @kshegunov

              Thanks. Agree that changing the build directory is a good way to structure things. just found out how;)

              Z 1 Reply Last reply
              0
              • Z zicx

                @kshegunov

                Thanks. Agree that changing the build directory is a good way to structure things. just found out how;)

                Z Offline
                Z Offline
                zicx
                wrote on last edited by
                #10

                @zicx

                I am still getting confused by this. Now I try to use a static library in another static library. copied over the app.pro lines, but it says
                Cannot open include file test_2.h: No such file or directory

                Any idea why that does not work? This all seems unnecessarily confusing

                K 1 Reply Last reply
                0
                • Z zicx

                  @zicx

                  I am still getting confused by this. Now I try to use a static library in another static library. copied over the app.pro lines, but it says
                  Cannot open include file test_2.h: No such file or directory

                  Any idea why that does not work? This all seems unnecessarily confusing

                  K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #11

                  @zicx
                  In general it is always a bit confusing when you are using relative path' because you are very often not based in the folder you are expecting.

                  @kshegunov has posted already

                  message("pwd: " $$PWD)
                  

                  This allows you to see where you are actually based. Your last message does not hold enough information for giving you better advise, but most likely there is an issue with your folders and relative path'.

                  Vote the answer(s) that helped you to solve your issue(s)

                  Z 1 Reply Last reply
                  1
                  • K koahnig

                    @zicx
                    In general it is always a bit confusing when you are using relative path' because you are very often not based in the folder you are expecting.

                    @kshegunov has posted already

                    message("pwd: " $$PWD)
                    

                    This allows you to see where you are actually based. Your last message does not hold enough information for giving you better advise, but most likely there is an issue with your folders and relative path'.

                    Z Offline
                    Z Offline
                    zicx
                    wrote on last edited by zicx
                    #12

                    @koahnig

                    Thanks a lot for your comment

                    message("pwd in SharedLib.pro: " $$PWD) 
                    
                     #automatically generate by QT when 'adding library' (via right click on the project  
                    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SharedLib_2/release/ -lSharedLib_2
                    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SharedLib_2/debug/ -lSharedLib_2
                    
                    INCLUDEPATH += $$PWD/../SharedLib_2
                    DEPENDPATH += $$PWD/../SharedLib_2
                    
                    # also added direct path now since it was suggested rel path makes issues 
                    win32:CONFIG(release, debug|release): LIBS += -LC:/CPP/Test/SharedLib_2/release/ -lSharedLib_2
                    else:win32:CONFIG(debug, debug|release): LIBS += -LC:/CPP/Test/SharedLib_2/debug/ -lSharedLib_2
                    
                    INCLUDEPATH += C:/CPP/Test/SharedLib_2
                    DEPENDPATH += C:/CPP/Test/SharedLib_2
                    

                    This is the output from the message from SharedLib.pro

                    Project MESSAGE: pwd in SharedLib.pro:  C:/CPP/Test/SharedLib
                    

                    This is what I get from the message in the application file Test.app

                    Project MESSAGE: pwd in test.pro:  C:/CPP/Test/Test
                    

                    The file SharedLib_2 is building in

                    C:\CPP\Test\SharedLib_2\debug
                    

                    Where .dll and library files can be found. The sharedlib_2.h file is in

                    C:\CPP\Test\SharedLib_2
                    

                    As you suggested, I added a manual includepat and dedpendpath but I still get

                    C:\CPP\Test\SharedLib\sharedlib.cpp:4: error: C1083: Cannot open include file: 'sharedlib_2.h': No such file or directory
                    

                    btw, I am running this on windows. QT seems to like the / when creating paths automatically, so I used that as well

                    K 1 Reply Last reply
                    0
                    • Z zicx

                      @koahnig

                      Thanks a lot for your comment

                      message("pwd in SharedLib.pro: " $$PWD) 
                      
                       #automatically generate by QT when 'adding library' (via right click on the project  
                      win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SharedLib_2/release/ -lSharedLib_2
                      else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SharedLib_2/debug/ -lSharedLib_2
                      
                      INCLUDEPATH += $$PWD/../SharedLib_2
                      DEPENDPATH += $$PWD/../SharedLib_2
                      
                      # also added direct path now since it was suggested rel path makes issues 
                      win32:CONFIG(release, debug|release): LIBS += -LC:/CPP/Test/SharedLib_2/release/ -lSharedLib_2
                      else:win32:CONFIG(debug, debug|release): LIBS += -LC:/CPP/Test/SharedLib_2/debug/ -lSharedLib_2
                      
                      INCLUDEPATH += C:/CPP/Test/SharedLib_2
                      DEPENDPATH += C:/CPP/Test/SharedLib_2
                      

                      This is the output from the message from SharedLib.pro

                      Project MESSAGE: pwd in SharedLib.pro:  C:/CPP/Test/SharedLib
                      

                      This is what I get from the message in the application file Test.app

                      Project MESSAGE: pwd in test.pro:  C:/CPP/Test/Test
                      

                      The file SharedLib_2 is building in

                      C:\CPP\Test\SharedLib_2\debug
                      

                      Where .dll and library files can be found. The sharedlib_2.h file is in

                      C:\CPP\Test\SharedLib_2
                      

                      As you suggested, I added a manual includepat and dedpendpath but I still get

                      C:\CPP\Test\SharedLib\sharedlib.cpp:4: error: C1083: Cannot open include file: 'sharedlib_2.h': No such file or directory
                      

                      btw, I am running this on windows. QT seems to like the / when creating paths automatically, so I used that as well

                      K Offline
                      K Offline
                      koahnig
                      wrote on last edited by koahnig
                      #13

                      @zicx

                      In .pro files you should use '/' as folder separation. Windows is traditionally using '' but the qmake is following the linux way of declaration (history of early days). Anway Windows can work also with the '/' notation and this makes live much easier. qmake will consider in most cases as continuation line.

                      Looks like you should do a complete rerun of qmake for all projects and do a complete a rebuild. My guess is that something went wrong and the created make-files are not up-to-date.

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      2
                      • Z Offline
                        Z Offline
                        zicx
                        wrote on last edited by
                        #14

                        That fixed it. I assumed qmake runs on all files, so I may not have run it on that specific file. Thanks a lot.

                        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