Lapack conflicts

Issue #341 wontfix
Feras Salim created an issue

I’m not sure why Blaze picks up multiple Lapack versions on Mac when building with Cmake. Here’s the error:

In file included from /cmake-build-debug/_deps/blaze-src/blaze/math/dense/DenseMatrix.h:52:
/cmake-build-debug/_deps/blaze-src/blaze/math/lapack/clapack/potrf.h:60:6: error: conflicting types for 'spotrf_'
void spotrf_( char* uplo, blaze::blas_int_t* n, float* A, blaze::blas_int_t* lda,
     ^
/include/xflens/cxxlapack/netlib/interface/lapack.in.h:16510:1: note: previous declaration is here
LAPACK_IMPL(spotrf)(const char       *UPLO,
^
/include/xflens/cxxlapack/netlib/netlib.h:9:41: note: expanded from macro 'LAPACK_IMPL'
#   define     LAPACK_IMPL(x)           x##_
                                        ^
<scratch space>:199:1: note: expanded from here
spotrf_
^

Meanwhile here is the Cmake output:

find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
find_package(blaze REQUIRED)
message("blas version: ${BLAS_FOUND}")
message("lapack version: ${LAPACK_FOUND}")
message("blaze version: ${blaze_VERSION}")
blas version: TRUE
lapack version: TRUE
blaze version: 3.7

The expectation is that Blaze picks up only those found by Cmake.

I’m including it like so, which seems to execute the Blaze’s Cmake file so BlazeImport is being ignored, but I don’t think that’s an issue.

FetchContent_Declare(
        blaze
        GIT_REPOSITORY "https:///bitbucket.org/blaze-lib/blaze.git"
        GIT_TAG v3.7
)
FetchContent_MakeAvailable(blaze)

Comments (4)

  1. Klaus Iglberger

    Hi Feras!

    Thanks for reporting this potential issue. In this case, it is not a CMake problem, but a problem of different forward declarations for LAPACK functions. Both Flens and Blaze provide (non-standard) forward declarations for the according LAPACK Fortran functions. Unfortunately, these forward declarations differ, which causes the compilation error.

    Blaze tries to be compatible to the major LAPACK implementations (MKL, OpenBLAS, ...), but cannot provide compatibility to other C/C++-interfaces to LAPACK (such as Flens). A simple solution would be to not include both Blaze and Flens at the same time.

    I hope this helps,

    Best regards,

    Klaus!

  2. Feras Salim reporter

    Thanks @Klaus Iglberger indeed xtensor-blas relies on Flens and that caused the issue. Builds fine when I remove it. A bit of pain because I want to port from one to the other and that makes them incompatible in the same project.

  3. Log in to comment