Error while building molflow from source on Linux

I am trying to build molflow from source on Ubuntu server 24.04 LTS. I have all the necessary dependencies installed on my machine yet I have run into multiple issues.

Upon running cmake, I get the following error:

CMake Error at src_shared/cmake_modules/src_shared_gui/CMakeLists.txt:229 (find_package):
By not providing “FindStb.cmake” in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by “Stb”, but CMake did not find one.
Could not find a package configuration file provided by “Stb” with any of the following names:
StbConfig.cmake
stb-config.cmake
Add the installation prefix of “Stb” to CMAKE_PREFIX_PATH or set “Stb_DIR”
to a directory containing one of the above files. If “Stb” provides a
separate development package or SDK, be sure it has been installed.

I do have libstb-dev installed and can see it in the /usr/include folder.

It means that CMake doesn’t find stb. I don’t know why, maybe libstb-dev is not the correct package.

As in the guide, we recommend using vcpkg (vcpkg install stb), it will then configure and build fine.

Ubuntu 24.04 uses GNU13, so make sure you build the master branch, since some small fixes needed to be applied since the last release (Molflow 2.9.26 was built on Ubuntu 22.04 with GNU 11)

So, CMake was missing FindStb.cmake file. I tried to add the same from here.

However, during the compilation process the compiler doesn’t seem to find stb_image.h while can see it at /usr/include/stb/stb_image.h

Seems to be a very strange issue. I remember having run into this a couple of months ago, when built a copy of molflow from the master branch on Ubuntu 22.04 LTS. Now, I don’t remember how I solved that issue :upside_down_face:

Sorry, building on five operating systemn is extremely time consuming. I know that vcpkg works (I just built molflow mintes ago on Ubuntu 24.04), I recommend you do that. I don’t have time to find out why alternative ways fail :frowning: The vcpkg method is described step by step here: README.md · master · molflow_synrad / molflow · GitLab

Finally, solved the problem. Adding a FindStb.cmake to /usr/share/cmake/Modules/ and symlinks to the header files (from a cloned version of the stb repo from https://github.com/nothings/stb) in /usr/local/include (or the include_dir) solved the issue.

If its possible, making a Cmake config available for Stb in the main molflow repo could help solve some of these issues. I guess its possible to get CMake to fetch and build dependencies, when they are not found locally?

I haven’t had a chance to look into the details of how molflow has been packages with CMake. But, I am guessing it would be possible? I’d be happy to test version of it if needed.

Dependencies are managed by vcpkg. Please read the manual, I linked it twice above, it explains this. Of course you can try alternate ways but we won’t give support or modify the repo for that.

Thanks, I’ve had the chance to read the manual more than once. However, none of it explains gives the details of how vcpkg and cmake are used together to package molflow. I completely get your point about not being able to support alternate ways.

However, just changing Stb to stb in molflow/src_shared/cmake_modules/src_shared_gui/CMakeLists.txt in 229-231, solves all these problems independently.

229 find_package(stb REQUIRED)
230 message("-- Found STB " ${stb_INCLUDE_DIR})
231 target_include_directories(${PROJECT_NAME} PRIVATE ${stb_INCLUDE_DIR})

Its turns out that CMake doesn’t seem to recognise Stb

“none of it explains gives the details of how vcpkg and cmake are used together to package molflow”

I beg to differ, I copy-paste from the instructions the critical part:

  • ./vcpkg integrate install - note down the toolchain location in the command’s output (on Windows, with Visual Studio installed, this is not necessary)
  • and later at the build step:
  • cmake .. "-DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake" (toolchain location as you noted down)

When installing stb with vcpkg, the output is:

The package stb provides CMake targets:

    find_package(Stb REQUIRED)
    target_include_directories(main PRIVATE ${Stb_INCLUDE_DIR})

This is what I pasted to the CMake file - note the capital S. Also this is what the official instructions say: stb | vcpkg.link: Vcpkg Ports and Packages Explorer

I tested right now and CMake finds Stb:

[cmake] -- Found Stb: /Users/martonady/vcpkg/installed/arm64-osx/include
[cmake] -- Found STB /Users/martonady/vcpkg/installed/arm64-osx/include

I agree, I’ve been able to build molflow using vcpkg to install the dependencies without any issues on my personal machine. vcpkg comes with telemetry and I’ve had issues with while using it on servers and hence, the hesitation. However, it does help in solving some tricky problems that come with managing C++ header libraries.

I think Stb is consistent with the FindStb.cmake file in vcpkg. However, the CMake config files from a few other packages seem to use stb.

So, bottom line, anyone trying to build molflow without using vcpkg can just make the above mentioned change to build the package.

Many thanks for the feedback!
(If it helps, vcpkg telemetry can be disabled)
We’ll soon remove the stb dependency, it was used to load images for DearImGui, which we’re moving away from.

We have, for your info, removed the STB from the dependencies. Thanks again for the feedback.