Skip to content

Conversation

Dasux
Copy link

@Dasux Dasux commented Sep 17, 2025

This pull request is an attempt to fix #6364.

Fix-1: LAPACKE detection error by CMake

The Bug

on debian 12 (bookworm)... building GRASS failed with the following error
Could NOT find LAPACKE (missing: HAVE_LAPACKE_DGESV)

image

Even though liblapacke-dev and libopenblas-dev were installed, CMake couldn’t detect LAPACKE because the check relied on check_symbol_exists(), which doesn’t actually link against liblapacke.so.

Debugging

  1. created a build directory and ran the following
mkdir build && cd build
cmake .. 
  1. confirmed headers and library exists:
ls /usr/include/lapacke.h
ls /usr/lib/x86_64-linux-gnu/liblapacke.so
  1. wrote a tiny test program
#include <lapacke.h>
#include <stdio.h>

int main() {
    printf("LAPACKE_dgesv is here: %p\n", LAPACKE_dgesv);
    return 0;
}
  1. compile
gcc test_lapacke.c -o test_lapacke -llapacke -llapack -lblas
./test_lapacke.c
  1. output LAPACKE_dgesv is here: 0x7fe4658c1320
    This ensures that lapacke exists and is working fine

The Fix

Edited cmake/find_scripts/FindLAPACKE.cmake to replace the header-only check with a proper library check.
Initially it was

include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES ${LAPACKE_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${LAPACKE_INCLUDEDIR})
set(CMAKE_REQUIRED_QUIET ${LAPACKE_FIND_QUIETLY})
check_symbol_exists(LAPACKE_dgesv "lapacke.h" HAVE_LAPACKE_DGESV)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_QUIET)

Which was changed to

include(CheckLibraryExists)
# Look for include and library
find_path(LAPACKE_INCLUDE_DIR lapacke.h)
find_library(LAPACKE_LIBRARIES lapacke)

if(LAPACKE_INCLUDE_DIR AND LAPACKE_LIBRARIES)
    set(CMAKE_REQUIRED_INCLUDES ${LAPACKE_INCLUDE_DIR})
    set(CMAKE_REQUIRED_LIBRARIES ${LAPACKE_LIBRARIES})
    check_library_exists(lapacke LAPACKE_dgesv "" HAVE_LAPACKE_DGESV)
endif()

unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)

Fix-2: Automated Script for installing build dependencies

The scripts are in setup_grass_dev.sh and setup_grass_extra.sh.

@github-actions github-actions bot added docs markdown Related to markdown, markdown files CMake labels Sep 17, 2025
INSTALL.md Outdated
Comment on lines 378 to 382
```
```
```
```
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid markdown markup?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes--- it's my first time using markdown--- ill resolve it asap

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries ;) caught my eye when waking up

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the heads up--- ive resolved them 🙂

INSTALL.md Outdated
r-base-dev \
python3-termcolor \
libglu1-mesa-dev libgl1-mesa-dev \
subversion```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a multiline code block finishes with the ticks on another line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright----

INSTALL.md Outdated
## Authors
Markus Neteler and the GRASS Development Team
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats probably just a white space--- must've hit enter when editing the file

INSTALL.md Outdated
- [Guide to contributing on GitHub](./doc/development/github_guide.md)


## (N) Debian Bookworm (Debain 12)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## (N) Debian Bookworm (Debain 12)
## (N) Debian Bookworm (Debian 12)

@wenzeslaus
Copy link
Member

This is good, but the scripts need to be more organized. We are already building Docker images. Can we reuse or connect with that? So, there would be one single place and it would be tested regularly. Also, the installation instructions can use the script making maintenance easier.

@Dasux
Copy link
Author

Dasux commented Sep 17, 2025

This is good, but the scripts need to be more organized. We are already building Docker images. Can we reuse or connect with that? So, there would be one single place and it would be tested regularly. Also, the installation instructions can use the script making maintenance easier.

Thanks for the feedback! That makes sense — keeping scripts in one place and reusing the Docker setup would definitely make things more consistent. Could you point me to the Docker build scripts so I can take a look at how this could fit in?

@echoix
Copy link
Member

echoix commented Sep 17, 2025

This is good, but the scripts need to be more organized. We are already building Docker images. Can we reuse or connect with that? So, there would be one single place and it would be tested regularly. Also, the installation instructions can use the script making maintenance easier.

Thanks for the feedback! That makes sense — keeping scripts in one place and reusing the Docker setup would definitely make things more consistent. Could you point me to the Docker build scripts so I can take a look at how this could fit in?

The folder is docker/debian

- [Guide to contributing on GitHub](./doc/development/github_guide.md)


## (N) Debian Bookworm (Debian 12)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a dedicated page for this kind of information: https://grasswiki.osgeo.org/wiki/Compile_and_Install. There are lots of platforms to give instructions to... in my opinion this is not the place. Maybe we can link to that page (and update it wherever needed).

Copy link
Author

@Dasux Dasux Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasnt aware of this--- i'll remove this section from the docs

Additionally-- i think it would be better if I added the missing dependencies (if any) to docker/debian.... as @wenzeslaus suggested ----- a single script handling such things would be better

any thoughts?

]]


include(CheckLibraryExists)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation (admittedly with plenty of room to improve) is based on search for pkg-config files. Also Debian installs *.pc files for openblas (and cblas, lapacke): openblas.pc, blas-openblas.pc, lapack-openblas.pc. That should be enough. We should initially explore what is possibly missing for that to work.

It is possible to add configuration, e.g.: -DLAPACKE_PKGCONFIG=lapack-openblas.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried your suggestion — cmake .. now runs smoothly ( i must’ve overlooked that earlier).

However, when I run make install, I still hit errors related to MAPSET PERMANENT - permission denied. It seems the build process expects a valid GRASS location/mapset for thumbnail generation, which fails if none exists.

Do you think this should be handled in the build system (e.g. skipping thumbnails when no mapset is available), or is this more of a local environment setup issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Difficult to say without the log file.

Forgot to mention this page: https://grasswiki.osgeo.org/wiki/Compile_and_Install_With_CMake

@echoix
Copy link
Member

echoix commented Oct 7, 2025

Our Dockerfiles now use Debian 13, a change since this PR was opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake docs markdown Related to markdown, markdown files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Debian Bookworm: LAPACKE detection failures with CMake

4 participants