# Error while building molflow from source on Linux

**URL:** <https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667>\
**Category:** General discussion\
**Tags:** ubuntu, linux, molflow\
**Created:** [November 12, 2024, 3:00pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667 "2024-11-12T15:00:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fracton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/f/dbc845/32.png) [@fracton](https://molflow-forum.web.cern.ch/u/fracton)\
**Post date:** [November 12, 2024, 3:00pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/1 "2024-11-12T15:00:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [November 12, 2024, 3:25pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/2 "2024-11-12T15:25:20Z")

</div>

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](https://learn.microsoft.com/en-us/cpp/build/walkthrough-build-debug-wsl2?view=msvc-170), 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)

---

<div class="post-metadata">

**Author:** ![fracton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/f/dbc845/32.png) [@fracton](https://molflow-forum.web.cern.ch/u/fracton)\
**Post date:** [November 12, 2024, 3:36pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/3 "2024-11-12T15:36:37Z")

</div>

> [@maarton](#):
>
> It means that CMake doesn’t find stb. I don’t know why, maybe libstb-dev is not the correct package.

So, CMake was missing `FindStb.cmake` file. I tried to add the same from [here](https://github.com/adobe/USD-Fileformat-plugins/blob/cb0e91b914eb71238c18c4332c18d4fbfae403ae/cmake/FindSTB.cmake).

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 🙃

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [November 12, 2024, 3:42pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/4 "2024-11-12T15:42:45Z")

</div>

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 ☹ The vcpkg method is described step by step here: [README.md · master · molflow\_synrad / molflow · GitLab](https://gitlab.cern.ch/molflow_synrad/molflow/-/blob/master/README.md#install-dependencies-using-vcpkg)

---

<div class="post-metadata">

**Author:** ![fracton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/f/dbc845/32.png) [@fracton](https://molflow-forum.web.cern.ch/u/fracton)\
**Post date:** [November 12, 2024, 4:58pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/5 "2024-11-12T16:58:32Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [November 12, 2024, 5:20pm UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/6 "2024-11-12T17:20:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fracton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/f/dbc845/32.png) [@fracton](https://molflow-forum.web.cern.ch/u/fracton)\
**Post date:** [November 13, 2024, 2:40am UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/7 "2024-11-13T02:40:38Z")

</div>

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.

```auto
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`

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [November 13, 2024, 7:09am UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/8 "2024-11-13T07:09:23Z")

</div>

“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:

```auto
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](https://vcpkg.link/ports/stb)

I tested right now and CMake finds Stb:

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

```

---

<div class="post-metadata">

**Author:** ![fracton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/f/dbc845/32.png) [@fracton](https://molflow-forum.web.cern.ch/u/fracton)\
**Post date:** [November 13, 2024, 7:49am UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/9 "2024-11-13T07:49:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [November 13, 2024, 8:00am UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/10 "2024-11-13T08:00:54Z")

</div>

Many thanks for the feedback!  
(If it helps, vcpkg telemetry can be [disabled](https://learn.microsoft.com/en-us/vcpkg/about/privacy#how-to-opt-out))  
We’ll soon remove the stb dependency, it was used to load images for DearImGui, which we’re moving away from.

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [November 14, 2024, 9:37am UTC](https://molflow-forum.web.cern.ch/t/error-while-building-molflow-from-source-on-linux/667/11 "2024-11-14T09:37:08Z")

</div>

We have, for your info, [removed](https://gitlab.cern.ch/molflow_synrad/molflow/-/commit/c64602312c55f3a0e8d15965eb1ce8c6d88586db) the STB from the dependencies. Thanks again for the feedback.
