Error: no BLAS/LAPACK library loaded!

This error started popping up. Is there a cure?

context?

I call

function dgetrf!(m::IT, n::IT, A::SubArray{FT, 1, Vector{FT}, Tuple{UnitRange{IT}}, true}, lda::IT, ipiv::SubArray{IT, 1, Vector{IT}, Tuple{UnitRange{IT}}, true}) where {IT, FT}
    info = Ref{LinearAlgebra.BLAS.BlasInt}()
    @show __blas_lib
    @show __DGETRF_PTR = dlsym(__blas_lib, @__blas(dgetrf_))
    ccall(__DGETRF_PTR, Cvoid,
        (Ref{LinearAlgebra.BLAS.BlasInt}, Ref{LinearAlgebra.BLAS.BlasInt}, Ptr{FT},
            Ref{LinearAlgebra.BLAS.BlasInt}, Ptr{LinearAlgebra.BLAS.BlasInt}, Ptr{LinearAlgebra.BLAS.BlasInt}),
        m, n, A, lda, ipiv, info)
    @show info[]
    return info[] #Error code is stored in LU factorization type
end

The printouts are

__blas_lib = Ptr{Nothing} @0x0000000065e00000                            
__DGETRF_PTR = dlsym(__blas_lib, #= C:\Users\pkonl\Documents\00WIP\Sparspak.jl\src\SparseSpdMethod\SpkSpdMMops.jl:226 =# @__blas(dgetrf_)) = Ptr{Nothing} @0x0000000065e0c0d4                                              
Error: no BLAS/LAPACK library loaded!                                    
info[] = 233980048 

The blas library was opened as const __blas_lib = dlopen(LinearAlgebra.BLAS.libblastrampoline).

That is not going to work. If you are going to use dlopen, this needs to be done at runtime, not during precompilation.

The closest would be:

module Foo

const __blas_lib_ref = Ref{Ptr{Nothing}}()

function __init__()
    __blas_lib_ref[] = dlopen(LinearAlgebra.BLAS.libblastrampoline).
end

end
3 Likes

That is a good point. So far I have only tested it, and that worked. Your code looks great. Thanks!