# CMake Not Finding HSL and METIS Libraries when Building CasADi + IPOPT + HSL in Dockerfile

**URL:** https://discourse.cmake.org/t/cmake-not-finding-hsl-and-metis-libraries-when-building-casadi-ipopt-hsl-in-dockerfile/12806
**Category:** Usage
**Tags:** os:linux
**Created:** [October 21, 2024, 9:24am UTC](https://discourse.cmake.org/t/cmake-not-finding-hsl-and-metis-libraries-when-building-casadi-ipopt-hsl-in-dockerfile/12806 "2024-10-21T09:24:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ebu](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@ebu](https://discourse.cmake.org/u/ebu)
#### Post date: [October 21, 2024, 9:24am UTC](https://discourse.cmake.org/t/cmake-not-finding-hsl-and-metis-libraries-when-building-casadi-ipopt-hsl-in-dockerfile/12806/1 "2024-10-21T09:24:07Z")

</div>

**Hi everyone,**

I’m trying to build **CasADi** with **IPOPT** and **HSL** inside a Docker environment. I’ve been following the instructions from [this guide](https://github.com/ami-iit/ami-commons/blob/master/doc/casadi-ipopt-hsl.md), but I keep running into an issue with CMake not being able to locate the **HSL** and **METIS** libraries.

Here’s a summary of the issue:

### **Problem Details:**

When building inside the Dockerfile, I encounter the following errors during the CMake configuration process:

```auto
-- x86_64 architecture detected - setting flag -fPIC
HSL: find via CONFIG
-- Could NOT find HSL (missing: HSL_DIR)
HSL: 0
-- Could not find HSL; looking in environmental variable HSL ()
debug HSL_FOUND
get_property(PKG_HELP CACHE WITH_BUILD_IPOPT PROPERTY HELPSTRING)
get_property(PKG_HELP CACHE WITH_BUILD_MUMPS PROPERTY HELPSTRING)
METIS: find via CONFIG
-- Could NOT find METIS (missing: METIS_DIR)
METIS: 0
-- Found METIS: /usr/lib/x86_64-linux-gnu/libmetis.so
-- Found METIS include dir: /usr/include

```

### **CMake Command in Dockerfile:**

Here’s the CMake and make commands I’m using in the Dockerfile:

```auto
cd /root/robot-code/casadi/build && \

cmake \
    -DWITH_IPOPT:BOOL=ON \
    -DWITH_HSL:BOOL=ON \
    -DWITH_PYTHON=ON \
    -DINCLUDE_PREFIX:PATH=/robot-code/CoinIpopt/install/include \
    -DCMAKE_PREFIX:PATH=lib/cmake/casadi \
    -DLIB_PREFIX:PATH=/robot-code/CoinIpopt/install/lib \
    -DBIN_PREFIX:PATH=/robot-code/CoinIpopt/install/bin ..

make && \

make install

```

### **What I’ve Tried:**

Here’s what’s strange:

- **When I run the last three commands manually in the terminal, everything works perfectly** , and **HSL** is correctly detected and used by CMake. However, when these exact same commands are executed in the **Dockerfile** , I get the error that HSL cannot be found.

I suspect this issue might be related to how the environment is set up in the Docker build context, but I haven’t been able to pinpoint the exact cause.

### **Questions:**

1. Has anyone encountered similar issues when building **CasADi** , **IPOPT** , and **HSL** within Docker, where the build works manually but fails inside the Dockerfile?
2. Could there be a difference in how environment variables or paths are handled in the Docker build context versus an interactive shell, causing the `HSL_DIR` or `METIS_DIR` to not be set correctly?
3. Are there any specific flags I should add to CMake or Docker to ensure the paths for HSL and METIS are resolved correctly?

Any guidance or suggestions would be greatly appreciated!

Thanks in advance for any help!
