[C++] Precompiled Boost dependencies

Let’s say our software need C++ Boost precompiled libraries, and cloning & compiling Boost may take 20 minutes. so I already added ready to use Boost precompiled libraries (.lib / .a) to my Github repo.

Did can I add those libs into my snapcraft.yaml? or everything need to be compiled from source code for multi platforms and architectures purpose ?

Thank you.

You can certainly include binaries in your Snapcraft project. That just means that you’ll need to make sure you provide binaries for all the architectures you want to build your snap for, and that the binaries are compatible with the base snap you’re targeting (e.g. you’ll likely have problems if the binaries are compiled against a newer libstdc++ than that provided by the base).

With that said, the Ubuntu archive provides compiled versions of most Boost libraries. You should be able to use them with a combination of build-packages (to make the headers available) and stage-packages (to include the libraries you need in your snap). As the packages in the Ubuntu archive are available for all supported architectures, this might be easier to get working for multiple architectures than checking binaries into your repo.

I got it, I will tray to use Ubuntu archive for better user experience.
Let’s say I need all Boost headers, and only filesystem and thread Boost libraries.
Did this is correct please?

  - libboost
  - libboost-filesystem
  - libboost-thread

Thank you.

For the filesystem and thread libraries, you’d want the following in build-packages:

 - libboost-filesystem-dev
 - libboost-thread-dev

You’d want to stage the package containing the corresponding libraries. If you’re using core18 as a base, then it would probably be:

 - libboost-filesystem1.65.1
 - libboost-thread1.65.1

If you’re using core20, then replace 1.65.1 with 1.71.

Thank you so much sir.