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. Using a Static Library I Created
Forum Updated to NodeBB v4.3 + New Features

Using a Static Library I Created

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 4 Posters 5.2k 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.
  • O Offline
    O Offline
    ofmrew
    wrote on 30 Jul 2022, 22:59 last edited by
    #21

    I believe that I start from the beginning by creating a new library and then try to use it.

    1 Reply Last reply
    0
    • O ofmrew
      30 Jul 2022, 20:26

      @ofmrew Since the include statement has the error file not found is it looking for a file and not an entry in the library?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Aug 2022, 06:32 last edited by
      #22

      @ofmrew said in Using a Static Library I Created:

      Since the include statement has the error file not found is it looking for a file and not an entry in the library?

      Include files are not entries in libraries. If your header file is not found then check whether your added correct include folder in INCLUDEPATH

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply 1 Aug 2022, 12:45
      0
      • J jsulm
        1 Aug 2022, 06:32

        @ofmrew said in Using a Static Library I Created:

        Since the include statement has the error file not found is it looking for a file and not an entry in the library?

        Include files are not entries in libraries. If your header file is not found then check whether your added correct include folder in INCLUDEPATH

        O Offline
        O Offline
        ofmrew
        wrote on 1 Aug 2022, 12:45 last edited by
        #23

        @jsulm As I understand it, the .h files in the library I created are in a list of (I am not sure of the exact term) items in the library. I assume also that the compiler will look first at the header files in the project and then in libraries. If that is correct then either the library could not be found or the library does not include the header. If I could print the contents of the library then I could answer that question. It seem straight forward in Linux, but not Win.

        Also I would like to point out that the Qt documentation is inconsistent, in one place it shows the full Win path, starting with the drive letter for windows and the -L and -l for the path and the library, respectively. It would seem that there are few problems encountered by Linux users, but that is not the case for Win users. Nearly all of the examples are for Linux, not windows. If there was only one example that was win based, complete and that worked, then I could validate it on my system, I could then make some progress. Is CMAKE the solution, not QMAKE? Someone have a cmake example the meets the above criteria?

        J 2 Replies Last reply 2 Aug 2022, 11:27
        0
        • O ofmrew
          1 Aug 2022, 12:45

          @jsulm As I understand it, the .h files in the library I created are in a list of (I am not sure of the exact term) items in the library. I assume also that the compiler will look first at the header files in the project and then in libraries. If that is correct then either the library could not be found or the library does not include the header. If I could print the contents of the library then I could answer that question. It seem straight forward in Linux, but not Win.

          Also I would like to point out that the Qt documentation is inconsistent, in one place it shows the full Win path, starting with the drive letter for windows and the -L and -l for the path and the library, respectively. It would seem that there are few problems encountered by Linux users, but that is not the case for Win users. Nearly all of the examples are for Linux, not windows. If there was only one example that was win based, complete and that worked, then I could validate it on my system, I could then make some progress. Is CMAKE the solution, not QMAKE? Someone have a cmake example the meets the above criteria?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 2 Aug 2022, 11:27 last edited by
          #24

          @ofmrew said in Using a Static Library I Created:

          As I understand it, the .h files in the library I created are in a list of (I am not sure of the exact term) items in the library

          Don't know what you mean. Header files are not entries in a library. They are text files which can be located in any location - that is why you need to tell the compiler where to find them using INCLUDEPATH. There is really not much to say, simply set INCLUDEPATH properly...

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • O ofmrew
            1 Aug 2022, 12:45

            @jsulm As I understand it, the .h files in the library I created are in a list of (I am not sure of the exact term) items in the library. I assume also that the compiler will look first at the header files in the project and then in libraries. If that is correct then either the library could not be found or the library does not include the header. If I could print the contents of the library then I could answer that question. It seem straight forward in Linux, but not Win.

            Also I would like to point out that the Qt documentation is inconsistent, in one place it shows the full Win path, starting with the drive letter for windows and the -L and -l for the path and the library, respectively. It would seem that there are few problems encountered by Linux users, but that is not the case for Win users. Nearly all of the examples are for Linux, not windows. If there was only one example that was win based, complete and that worked, then I could validate it on my system, I could then make some progress. Is CMAKE the solution, not QMAKE? Someone have a cmake example the meets the above criteria?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 2 Aug 2022, 11:27 last edited by
            #25

            @ofmrew said in Using a Static Library I Created:

            in one place it shows the full Win path, starting with the drive letter for windows and the -L and -l for the path and the library

            Yes, because linking works differently on Windows...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            O 1 Reply Last reply 2 Aug 2022, 13:18
            0
            • J jsulm
              2 Aug 2022, 11:27

              @ofmrew said in Using a Static Library I Created:

              in one place it shows the full Win path, starting with the drive letter for windows and the -L and -l for the path and the library

              Yes, because linking works differently on Windows...

              O Offline
              O Offline
              ofmrew
              wrote on 2 Aug 2022, 13:18 last edited by
              #26

              @jsulm The library path in Win11 is D:\QtPrograms\MyLibraries\libMy3DLib.a

              When I use
              INCLUDEPATH +=
              -LD:/qtprograms/MyLibraries/

              LIBS += -lMy3DLib
              I get
              :-1: error: No rule to make target 'D:/qtprograms/TestMy3DLib/../MyLibraries/libMy3DLibd.a', needed by 'debug/TestMy3DLib.exe'. Stop.
              I remember seeing another entry for debug in some post any idea?

              J 1 Reply Last reply 2 Aug 2022, 13:28
              0
              • O ofmrew
                2 Aug 2022, 13:18

                @jsulm The library path in Win11 is D:\QtPrograms\MyLibraries\libMy3DLib.a

                When I use
                INCLUDEPATH +=
                -LD:/qtprograms/MyLibraries/

                LIBS += -lMy3DLib
                I get
                :-1: error: No rule to make target 'D:/qtprograms/TestMy3DLib/../MyLibraries/libMy3DLibd.a', needed by 'debug/TestMy3DLib.exe'. Stop.
                I remember seeing another entry for debug in some post any idea?

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 2 Aug 2022, 13:28 last edited by
                #27

                @ofmrew said in Using a Static Library I Created:

                INCLUDEPATH +=
                -LD:/qtprograms/MyLibraries/

                What is this?!
                INCLUDEPATH contains the folders where include headers are located and has nothing to do with library files (.so, .dll, .lib, .a).
                -L defines the path where libraries are located. -l defines library file name.
                So, it should be like:

                INCLUDEPATH += PAT_TO_HEADER_FILE_FOLDER
                LIBS += -lD:/qtprograms/MyLibraries/libMy3DLib.a
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                21/27

                30 Jul 2022, 22:59

                • Login

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