2

I need to parse a large XML file using property tree in boost libraries. How to use them ONLY instead of including the whole boost libraries?

Alaa Agwa
  • 162
  • 1
  • 12
  • https://stackoverflow.com/a/10818989/453271 can help. In short, you can minimise boost libraries set by including only those that `Boost.PropertyTree` depends on. You'll still need "core" headers with common preprocessor definitions etc. – Andriy Tylychko Aug 19 '18 at 11:08
  • @AndriyTylychko there's one more issue, I can't include it in my qt project and it gives me error including some files like this one: mini-boost\libs\mpi\src\python\collectives.cpp:14: error: C1083: Cannot open include file: 'boost/python.hpp': No such file or directory – Alaa Agwa Aug 19 '18 at 11:52

2 Answers2

2

There's no need for you whatsoever to include the whole boost libraries. For example, if you look in the quick tutorial in the appropriate boost documentation page for XML Property Trees, you see that you only need to include the following:

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

In order to get the fully functional tutorial code compile error-free.

So, this answers your question:

How to use them ONLY instead of including the whole boost libraries?

But, in case you actually meant having to package/deploy the whole boost libraries in contrast to including the whole boost libraries, then you have the bcp tool, itself a part of boost (also mentioned this post) to aid you sift through the entire ordeal and know exactly what parts of the library are needed to use the property_tree library.

I have run this for you:

bcp --list property_tree

and the results are well... way to long to put in this answer. As in, the property_tree library itself is dependent on quite a large portion out of the entire boost libraries.

So, there won't be such a noticeable difference between packaging the entire boost as part of your project, and shipping only whats needed for property_tree to build.

Bottom line: If all you need is XML parsing capabilities and all of boost is too big for you then I suggest checking out one of the many XML libraries out there such as TinyXML-2 -- it is a "simple, small, efficient, C++ XML parser that can be easily integrated into other programs."

Geezer
  • 5,600
  • 18
  • 31
  • I want just only the property tree because the project is too small and there's no use adding the whole boost libraries so that I want to use only this library. – Alaa Agwa Aug 19 '18 at 11:51
  • 1
    @AlaaAgwa Edited to hopefully better answer your pondering. – Geezer Aug 19 '18 at 12:19
  • thanks alot, I did what you told me and it works but I can't compile it inside my qt project and it gives me missing files like this one: mini-boost\libs\mpi\src\python\collectives.cpp:14: error: C1083: Cannot open include file: 'boost/python.hpp': No such file or directory – Alaa Agwa Aug 19 '18 at 12:23
  • @SkepticalEmpiricist Nah. It sounds like OP is "compiling" the library. That can't work since all parts are header-only – sehe Aug 19 '18 at 13:56
  • Thanks alot @SkepticalEmpiricist, it works as you said :) – Alaa Agwa Aug 27 '18 at 09:27
  • @AlaaAgwa Glad to have helped. BTW you have enough reputation to upvote together with accepting the answer, in case you wanted to. – Geezer Aug 27 '18 at 09:31
  • @SkepticalEmpiricist I accepted it and upvoted it also ;) – Alaa Agwa Aug 27 '18 at 09:33
  • @AlaaAgwa Cheers mate : ) – Geezer Aug 27 '18 at 09:33
2

The direct question is: it's header-only, so no real meaning whatsoever.

What's way more important is this:

I need to parse a large XML file using property tree

You need to pick one:

  1. I need to parse a large XML file
  2. I need to [...] use [red.] property tree

Boost Property Tree is NOT an XML library. If you need to parse general purpose XML, you can't use Boost Property Tree or you'll regret the choice pretty soon. See What XML parser should I use in C++?`

sehe
  • 374,641
  • 47
  • 450
  • 633