# find\_package(BLAS) does not find OpenBLAS

**URL:** <https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [June 27, 2023, 9:00am UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414 "2023-06-27T09:00:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CountZero](https://discourse.cmake.org/user_avatar/discourse.cmake.org/countzero/32/3558_2.png) [@CountZero](https://discourse.cmake.org/u/CountZero)\
**Post date:** [June 27, 2023, 9:00am UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/1 "2023-06-27T09:00:03Z")

</div>

Hi,

I am using the `llama.cpp` project to evaluate LLMs. But on Windows I am running into a problem with CMake: The `find_package(BLAS)` invocation does not find OpenBLAS.

**Steps to reproduce**

1. Unpack the `fOpenBLAS-0.3.23-x64.zip`f inside the projects `./build` directory.

2. Execute:

```auto
cmake `
    --debug-find `
    -DLLAMA_BLAS=ON `
    -DLLAMA_BLAS_VENDOR=OpenBLAS `
    ..

```

**Debug Output**

The file `C:/llama.cpp/build/OpenBLAS/lib/libopenblas.lib` does exist and the `find_library` method location should match.

See [llama.cpp/CMakeLists.txt at master-0be54f7 · ggerganov/llama.cpp · GitHub](https://github.com/ggerganov/llama.cpp/blob/master-0be54f7/CMakeLists.txt#L166) for the implementation.

```auto
CMake Debug Log at C:/Users/CountZero/miniconda3/Lib/site-packages/cmake/data/share/cmake-3.26/Modules/FindBLAS.cmake:343 (find_library):
  find_library called with the following settings:

    VAR: BLAS_openblas_LIBRARY
    NAMES: "openblas"
    Documentation: Path to a library.
    Framework
      Only Search Frameworks: 0
      Search Frameworks Last: 0
      Search Frameworks First: 0
    AppBundle
      Only Search AppBundle: 0
      Search AppBundle Last: 0
      Search AppBundle First: 0
    CMAKE_FIND_USE_CMAKE_PATH: 1
    CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
    CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
    CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
    CMAKE_FIND_USE_INSTALL_PREFIX: 1

  find_library considered the following locations:

    C:/llama.cpp/build/()openblas(\.lib)

  The item was not found.

Call Stack (most recent call first):
  C:/Users/CountZero/miniconda3/Lib/site-packages/cmake/data/share/cmake-3.26/Modules/FindBLAS.cmake:775 (check_blas_libraries)
  CMakeLists.txt:173 (find_package)

-- Could NOT find BLAS (missing: BLAS_LIBRARIES)

```

The issue [https://github.com/ggerganov/llama.cpp/issues/627](https://github.com/ggerganov/llama.cpp/issues/627) is related.

Is this a bug of CMake? Is there a workaround?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [July 1, 2023, 8:58pm UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/2 "2023-07-01T20:58:24Z")

</div>

It looks like `BLAS_ROOT` should be set to `${LLAMA_BUILD_DIR}/OpenBLAS` (or similar). Does that help?

---

<div class="post-metadata">

**Author:** ![CountZero](https://discourse.cmake.org/user_avatar/discourse.cmake.org/countzero/32/3558_2.png) [@CountZero](https://discourse.cmake.org/u/CountZero)\
**Post date:** [July 3, 2023, 1:21pm UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/3 "2023-07-03T13:21:43Z")

</div>

Hi,

thank you for the advice.

I set the `BLAS_ROOT` variable:

```PowerShell
cmake `
    -DBLAS_ROOT="${pathToOpenBLAS}" `
    -DLLAMA_BLAS=ON `
    -DLLAMA_BLAS_VENDOR=OpenBLAS `
    ..

```

And used the following values of `$pathToOpenBLAS`:

1. `../../OpenBLAS`
2. `../../OpenBLAS/`
3. `C:/absolute/path/to/OpenBLAS`
4. `C:/absolute/path/to/OpenBLAS/`

But the error message is still the same:

> – Could NOT find BLAS (missing: BLAS\_LIBRARIES)  
> CMake Warning at CMakeLists.txt:225 (message):  
> BLAS not found, please refer to  
> [https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors](https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors)  
> to set correct LLAMA\_BLAS\_VENDOR

So it sadly does not help.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [July 4, 2023, 10:54am UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/4 "2023-07-04T10:54:00Z")

</div>

Does `--debug-find` help figure out where CMake is looking at least?

---

<div class="post-metadata">

**Author:** ![CountZero](https://discourse.cmake.org/user_avatar/discourse.cmake.org/countzero/32/3558_2.png) [@CountZero](https://discourse.cmake.org/u/CountZero)\
**Post date:** [July 4, 2023, 2:04pm UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/5 "2023-07-04T14:04:05Z")

</div>

@ben.boeckel Yes, setting the `BLAS_ROOT` variable to `../../OpenBLAS` causes CMake to search at the right location:

```auto
CMake Debug Log at C:/Users/CountZero/miniconda3/Lib/site-packages/cmake/data/share/cmake-3.26/Modules/FindBLAS.cmake:343 (find_library):
  find_library called with the following settings:

    VAR: BLAS_openblas_LIBRARY
    NAMES: "openblas"
    Documentation: Path to a library.
    Framework
      Only Search Frameworks: 0
      Search Frameworks Last: 0
      Search Frameworks First: 0
    AppBundle
      Only Search AppBundle: 0
      Search AppBundle Last: 0
      Search AppBundle First: 0
    CMAKE_FIND_USE_CMAKE_PATH: 1
    CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
    CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
    CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
    CMAKE_FIND_USE_INSTALL_PREFIX: 1

  find_library considered the following locations:

    C:/absolute/path/to/OpenBLAS/lib/()openblas(\.lib)
    C:/absolute/path/to/OpenBLAS/()openblas(\.lib)
    [...]

```

But CMake still fails to “find” the `OpenBLAS` library:

```auto
[...]

  The item was not found.

Call Stack (most recent call first):
  C:/Users/CountZero/miniconda3/Lib/site-packages/cmake/data/share/cmake-3.26/Modules/FindBLAS.cmake:775 (check_blas_libraries)
  CMakeLists.txt:181 (find_package)

-- Could NOT find BLAS (missing: BLAS_LIBRARIES)
CMake Debug Log at CMakeLists.txt:181 (find_package):
  find_package considered the following paths for FindBLAS.cmake:

  The file was found at

    C:/Users/CountZero/miniconda3/Lib/site-packages/cmake/data/share/cmake-3.26/Modules/FindBLAS.cmake

  The module is considered not found due to BLAS_FOUND being FALSE.

CMake Warning at CMakeLists.txt:238 (message):
  BLAS not found, please refer to
  https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors
  to set correct LLAMA_BLAS_VENDOR

```

I am using the `openblas-0.3.23-x64.zip` from [Release OpenBLAS 0.3.23 version · xianyi/OpenBLAS · GitHub](https://github.com/xianyi/OpenBLAS/releases/tag/v0.3.23).

---

<div class="post-metadata">

**Author:** ![Peter\_Featherstone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/peter_featherstone/32/4279_2.png) [@Peter\_Featherstone](https://discourse.cmake.org/u/Peter_Featherstone)\
**Post date:** [February 6, 2024, 11:17pm UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/6 "2024-02-06T23:17:58Z")

</div>

I have a similar issue. It can’t find reference implementations (libblas, libcblas) either

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 16, 2024, 2:12pm UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/7 "2024-02-16T14:12:46Z")

</div>

Has anyone made an issue for this to track it?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [March 10, 2024, 9:34am UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/8 "2024-03-10T09:34:19Z")

</div>

It seems to me the `cmake config package` is wrong:

bash-5.2$ head -50 /usr/local/Cellar/openblas/0.3.26/lib/cmake/openblas/OpenBLASConfig\*.cmake  
==\> /usr/local/Cellar/openblas/0.3.26/lib/cmake/openblas/OpenBLASConfig.cmake \<==

```cmake
SET(OpenBLAS_VERSION "0.3.26")
SET(OpenBLAS_INCLUDE_DIRS /usr/local/Cellar/openblas/0.3.26/include)
SET(OpenBLAS_LIBRARIES /usr/local/Cellar/openblas/0.3.26/lib/libopenblas.dylib)

```

==\> /usr/local/Cellar/openblas/0.3.26/lib/cmake/openblas/OpenBLASConfigVersion.cmake \<==

```cmake
set (PACKAGE_VERSION "0.3.26")
if (PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
  set (PACKAGE_VERSION_COMPATIBLE FALSE)
else ()
  set (PACKAGE_VERSION_COMPATIBLE TRUE)
  if (PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
    set (PACKAGE_VERSION_EXACT TRUE)
  endif ()
endif ()

```

bash-5.2$

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [March 10, 2024, 9:49am UTC](https://discourse.cmake.org/t/find-package-blas-does-not-find-openblas/8414/9 "2024-03-10T09:49:04Z")

</div>

> [@ben.boeckel](#):
>
> Has anyone made an issue for this to track it?

> <https://github.com/OpenMathLib/OpenBLAS/issues/4396>
>
> I can see \[here\](https://github.com/OpenMathLib/OpenBLAS/blob/develop/cmake/Open…BLASConfig.cmake.in) that there is a template for a well made find module for OpenBLAS. However, the find module provided with the pre-built releases is extremely basic and doesn't work without modification.
> 
> Where does the nicer find module get used? Is there a reason not to include it with the download?
