I'm trying to add a external library into my project in Qt Creator. Usually I am supposed to add the .dll, .lib or .a file (I am using Windows) when right-clicking my project > add library but in my case, there is no such file in the folder. Am I just blind and I keep overseeing it or do I have to create the file on my own or something like that? I would appreciate if there's a detailed solution for my problem.
-
1[Header-only library](https://en.wikipedia.org/wiki/Header-only). – thuga Mar 12 '20 at 14:24
-
@thuga It doesn't look like hedaer-only liberary. I suppose it must be builded by [cmake](https://cmake.org/) . – Konstantin T. Mar 12 '20 at 14:27
-
4@KonstantinT. It claims to be. It's even listed in that wikipedia page. – thuga Mar 12 '20 at 14:28
-
@KonstantinT. Indeed putting everything in a "src" folder instead of an "include" folder is quite misleading, but there are only ".hpp" files inside. Therefore there is nothing to build. – Fareanor Mar 12 '20 at 14:33
-
@Fareanor, Yes, you're right. I'm misled by src folder presence. – Konstantin T. Mar 13 '20 at 05:52
2 Answers
As already mentioned in comments, this is a header-only library.
You have a ArduinoJson.h file in the root of the repository that seems to include the whole library. You just have to #include it where needed and that should work.
If you don't want to #include with the full path, you can set the INCLUDEPATH
variable in your .pro file (details here).
For example:
.pro
INCLUDEPATH += path/to/ArduinoJson/
implementation
#include <ArduinoJson.h>

- 5,900
- 2
- 11
- 37
1- Download and Install CMake Here
2- Download your project sources Here
3- Extract your project to a source folder (Exemple : G:\Cmake\Sources\ArduinoJson-6.x
)
4- Run Cmake
5- Indicate the path of your project and where you want to generate your project for a later compilation of lib, dll
6- Click on Configure
7- Choose your IDE cible (Visual Studio 2010 in my case)
8- Click on Generate
9- Open your VC solution ("G:\Cmake\Build\ArduinoJson.sln"
)
10- Compile your project to get Libraries

- 1,368
- 8
- 9
-
That's a passable answer, but not to the question asked. In any case, such a roundabout process is unnecessary. The library's CMakeLists.txt can be added directly to the cmake project worked on in Qt Creator. It's kinda trivial. Cmake will take care of building the library if necessary, and of using its include paths in the user code. – Kuba hasn't forgotten Monica Mar 12 '20 at 14:55
-
@ReinstateMonica Since he didn't mention `CMake`, I thought he didn't know how to use it. Unfortunately, I dedicated a lot of time to write this answer. – Landstalker Mar 12 '20 at 15:06
-
Although there is no need of Cmake in this case, I might have to use it in the future. So thank you for your detailed answer – Schulp Mar 12 '20 at 15:51