Skip to content

[R-pkg-devel] Linking with OpenBLAS complains lapacke not found

4 messages · Sameh M. Abdulah, Brian G. Peterson, Tomas Kalibera

#
I am linking my package against openblas but it complains that lapacke is not found which I need for the installation.

I have another alternative to linking against MKL but I cannot find it using MKLROOT variable on CRAN servers.


?Sameh

Get Outlook for iOS<https://aka.ms/o0ukef>
#
On Sun, 2019-09-08 at 10:04 +0000, Sameh M. Abdulah wrote:
It isn't entirely clear what your question is, but shouldn't you just
be linking to the BLAS and leave the choice of BLAS to the individual
installation?  In most cases you should probably not be statically
linking to the BLAS.

Here is an old paper by Dirk with more information that might help you
sort it out.

https://cran.r-project.org/web/packages/gcbd/vignettes/gcbd.pdf

Regards,

Brian
#
Brian,

This is the code I am using to linking with BLAS using MKL or OpenBLAS

#MKL
if [ -n "$MKLROOT" ] && [ -d "$MKLROOT" ]; then
    echo "mkl_dir directory exists!"
    echo "Great... continue set-up"
    source ${MKLROOT}/bin/mklvars.sh intel64
    DEFINE_BLAS_LIBS_CMAKE="-DBLAS_LIBRARIES='-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl'"
    #DEFINE_BLAS_LIBS_CMAKE="-DBLAS_LIBRARIES='-L${MKLROOT}/lib\ -Wl,-rpath,${MKLROOT}/lib\ -lmkl_intel_lp64\ -lmkl_sequential\ -lmkl_core\ -lpthread\ -lm\ -ldl'"
    XFLAG="-DBLA_VENDOR=Intel"
else
    echo "MKL not found, trying to compile and use OpenBLAS"
    XFLAG="-DBLA_VENDOR=Open"
    USE_OPENBLAS='true'
fi

# openblas
if [ "true" == "$USE_OPENBLAS" ]
then
    if pkg-config --exists openblas
    then
        _LOCATION=`pkg-config --variable=libdir openblas`
        echo "OpenBLAS FOUND in [$_LOCATION]"
    else
        if [ "$BUILD_DEPENDENCIES" == "true" ]
        then
            echo "Building OpenBLAS..."
            cd $TMPDIR
            wget https://github.com/xianyi/OpenBLAS/archive/v0.3.3.tar.gz -O - | tar -zx
            cd OpenBLAS-0.3.3
            $MAKE -j  >/dev/null|| $MAKE || { echo 'OpenBLAS installation failed' ; exit 1; }
            $MAKE install PREFIX=$PREFIX
            export CPATH=$CPATH:$PREFIX/include
        else
            echo "####################"
            echo "OpenBLAS NOT FOUND"
            echo "Please download it from: https://github.com/xianyi/OpenBLAS/releases"
            echo "After installing it, set the proper PKG_CONFIG_PATH variable"
            echo ""
            err=1
        fi
    fi
fi


It works great but when OpenBLAS is using, my application cannot find lapacke library.
?On 9/8/19, 2:28 PM, "Brian G. Peterson" <brian at braverock.com> wrote:

        
On Sun, 2019-09-08 at 10:04 +0000, Sameh M. Abdulah wrote:
> I am linking my package against openblas but it complains that
    > lapacke is not found which I need for the installation.
    > 
    > I have another alternative to linking against MKL but I cannot find
    > it using MKLROOT variable on CRAN servers.
    
    It isn't entirely clear what your question is, but shouldn't you just
    be linking to the BLAS and leave the choice of BLAS to the individual
    installation?  In most cases you should probably not be statically
    linking to the BLAS.
    
    Here is an old paper by Dirk with more information that might help you
    sort it out.
    
    https://cran.r-project.org/web/packages/gcbd/vignettes/gcbd.pdf
    
    Regards,
    
    Brian
    
    -- 
    Brian G. Peterson
    ph: +1.773.459.4973
    im: bgpbraverock
#
Please refer to BLAS_LIBS, LAPACK_LIBS in Writing R Extensions. For an 
example package that uses BLAS/LAPACK, see e.g. "stats" or "Matrix". The 
package will then use the BLAS/LAPACK implementation as chosen by the 
user/system administrator at dynamic linking time (see R Installation 
and Administration Manual for the defailts) - be it say reference BLAS, 
OpenBLAS, MKL or other; as a package author, one does not have to care 
which one it is.

Best
Tomas
On 9/8/19 2:22 PM, Sameh M. Abdulah wrote: