Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the proper way of using header-only library?

I've ran into a confusion about how to properly use header-only library. Googling didn't help as I didn't find anything about using header-only libraries.

So my question is: Should I just copy the header files and paste them into my project folder and use them that way or should I link them to the project using C\C++ >> General >> Additional Include Directories?

like image 316
user3071028 Avatar asked Aug 26 '15 11:08

user3071028


2 Answers

I'd say copying the file to your project folder is preferable. That way your project is self contained. You could then give it to someone else and he would be able to build it without having to change any configuration.

Now, if you use boost which also has header-only libraries it is another story. Boost is easily obtainable and having your project depend on boost is less problematic. In that case I would add it in the Additional Includes.

like image 192
trenki Avatar answered Oct 21 '22 06:10

trenki


You can do either, it is really a question of convenience. Traditionally you would include them in your include path, but you can also put them in your project. Including them in your project makes it more self-contained and protects you from code-breaking library changes, but also means you have to install library security-related updates to each project's copy, for example.

like image 2
Tom Avatar answered Oct 21 '22 05:10

Tom