3

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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Schulp
  • 73
  • 6

2 Answers2

4

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>
Fareanor
  • 5,900
  • 2
  • 11
  • 37
0

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

enter image description here

6- Click on Configure
7- Choose your IDE cible (Visual Studio 2010 in my case)
enter image description here

8- Click on Generate

enter image description here
9- Open your VC solution ("G:\Cmake\Build\ArduinoJson.sln")
10- Compile your project to get Libraries

enter image description here

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