tlgf.space

C++ Package Management with Conan

I consider myself tough, but it had been a while since I did any C++ development. After years of being spolit by python’s pip, which lately has been turbo charged by poetry it was a curiosity of mine to see what was happening in the C++ community. This is my story.

Creating a Boilerplate

talk is cheap, show me the code! <-(click to skip to the github repo)

I do not use many (if any) third party packages in my ‘compiled language’ daily work. I do however, use a lot of virtual environments and python packages. I wondered if for more ‘userspace-y’ applications the good people of the internet were distributing useful libraries to do their compiled work.

It turns out they are, with the two main choices being:

  • [vcpkg](https://vcpkg.io) (Microsoft)
  • conan (community grown)

My decision making was split, but ultimately I couldn’t resist the branding of conan. Really though, the cmake first support is what appealed to me most, as my understanding of some of conan’s design goals is to be:

If I ever were to require c/c++ package management professionally, being able to self-host project packages is appealing for security/supply chain auditing, build caching etc.

To give a working reference of how to use conan, I wrote a tiny C++ program which pulls in the boost library for its command line parsing and its statistical implementations.

It runs in a GitHub actions pipeline by pulling in all the dependencies (namely boost) then compiling and linking: computeStatistics