I am trying to build Boost from source using emscripten.
One executable CMake project I have has a dependency on the following boost libraries:
- Boost::boost
- Boost::filesystem
- Boost::program_options
- Boost::graph
So I am building the requested boost libraries using the following commands:
git clone --recursive https://github.com/boostorg/boost.git --branch boost-1.85.0
cd boost
./bootstrap.sh
./b2 --show-libraries
<Here, I see graph is indeed listed, so are filesystem and program_options>
./b2 toolset=emscripten link=static variant=release threading=multi runtime-link=static filesystem program_options graph
This last command exits with the following error:
don't know how to make <e>graph
...found 1 target...
...can't find 1 target...
If I omit graph
from the build, boost builds fine. Why can’t I just build graph just like I can build filesystem, system and other libraries?
I’m using Ubuntu 22.04 from within a WSL environment, not sure if that matters.
2
Answers
I believe I found the solution, by replacing
graph
withheaders
.The
graph
folder does seem to be available now under theboost
subfolder, unfortunately I can't check if it really works because now I have another problem related to emscripten.So, I wanted to try this out. On my nix-setup I made an empty directory
emscripten_projects
withdefault.nix
:This tiny shell definition installs cmake and emscripten. The most of the work is to avoid permission errors on the emscripten cache (see here).
Next up, I built stuff like this:
This all builds like clockwork: (fullres mp4 here, 69MiB)
Demo Program
Let’s compile a demo,
main.cpp
:This specifically uses the linked-library feature
read_graphviz
because it is NOT header-only: