Using a Static Library I Created
-
wrote on 30 Jul 2022, 22:59 last edited by
I believe that I start from the beginning by creating a new library and then try to use it.
-
@ofmrew Since the include statement has the error file not found is it looking for a file and not an entry in the library?
@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
-
@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
wrote on 1 Aug 2022, 12:45 last edited by@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?
-
@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?
@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...
-
@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?
@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...
-
@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...
wrote on 2 Aug 2022, 13:18 last edited by@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? -
@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?@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
21/27