Unable to install CBLAS on Ubuntu

11,313

Solution 1

The recommended method is to install CBLAS as part of lapack, ATLAS or OpenBLAS. For complete instructions you may see here

  1. You need to first install BLAS either by sudo apt-get install libblas-dev or by compiling the original implementation:

    1.1. download latest version of the BLAS from http://www.netlib.org/blas/

    1.2. unarchive and go to the folder in the terminal and run make

    1.3. look for the file named blas_LINUX.a and save the address to this file

  2. compile the netlib cblas:

    2.1. download CBLAS from the same page

    2.2. unarchive

    2.3. open the file Makefile.in

    2.4. look for the line BLLIB = .../blas_LINUX.a

    2.5. put the address you had in step one here

    2.6. go to the terminal in unzipped cblas folder and run make

  3. look for the cblas.h file in the include folder and when you want to compile link gcc against this folder

Instructions from here. If looking CBLAS examples you may check here.

Solution 2

I tried the above method as well, and thought I was close to being successful, but ultimately couldn't get the program to recognize that I had installed CBLAS.

I eventually came across the comment to this question, which led me to the solution that immediately worked for me, to just install it from a pre-existing package.

sudo apt install libopenblas-dev

I hope you still find this answer useful 8 years after you asked the question.

Share:
11,313

Related videos on Youtube

user1096863
Author by

user1096863

Updated on September 18, 2022

Comments

  • user1096863
    user1096863 almost 2 years

    I am trying to install CBLAS on Ubuntu, and am, as far as I can see, following the instructions in the README file that came in the folder. When I do a 'make all', I get the following errors that I just do not understand:

    make[1]: Entering directory `/home/ubuntu/ernieProject_C/pascalInpaintCodes/CBLAS/t                                                                                                             esting'
    gfortran  -o xscblat1 c_sblat1.o c_sblas1.o ../lib/cblas_LINUX.a ../lib/cblas_LINUX                                                                                                             .a
    ../lib/cblas_LINUX.a(cblas_srotg.o): In function `cblas_srotg': cblas_srotg.c (.text+0x1): undefined reference to `srotg_'
    ../lib/cblas_LINUX.a(cblas_srot.o): In function `cblas_srot':cblas_srot.c:(.text+0x3b): undefined reference to `srot_'
    ../lib/cblas_LINUX.a(cblas_sswap.o): In function `cblas_sswap':cblas_sswap.c:(.text+0x21): undefined reference to `sswap_'
    ../lib/cblas_LINUX.a(cblas_sscal.o): In function `cblas_sscal':cblas_sscal.c:(.text+0x25): undefined reference to `sscal_'
    ../lib/cblas_LINUX.a(cblas_scopy.o): In function `cblas_scopy':cblas_scopy.c:(.text+0x21): undefined reference to `scopy_'
    ../lib/cblas_LINUX.a(cblas_saxpy.o): In function `cblas_saxpy':cblas_saxpy.c:(.text+0x2f): undefined reference to `saxpy_'
    ../lib/cblas_LINUX.a(sdotsub.o): In function `sdotsub_':sdotsub.f:(.text+0x7): undefined reference to `sdot_'
    ../lib/cblas_LINUX.a(snrm2sub.o): In function `snrm2sub_':snrm2sub.f:(.text+0x7): undefined reference to `snrm2_'
    ../lib/cblas_LINUX.a(sasumsub.o): In function `sasumsub_':sasumsub.f:(.text+0x7): undefined reference to `sasum_'
    ../lib/cblas_LINUX.a(isamaxsub.o): In function `isamaxsub_':isamaxsub.f:(.text+0x7): undefined reference to `isamax_'
    ../lib/cblas_LINUX.a(scasumsub.o): In function `scasumsub_':scasumsub.f:(.text+0x7): undefined reference to `scasum_'
    ../lib/cblas_LINUX.a(scnrm2sub.o): In function `scnrm2sub_':scnrm2sub.f:(.text+0x7): undefined reference to `scnrm2_'
    collect2: ld returned 1 exit status
    make[1]: *** [xscblat1] Error 1
    make[1]: Leaving directory `/home/ubuntu/ernieProject_C/pascalInpaintCodes/CBLAS/te                                                                                                             sting'
    make: *** [alltst] Error 2
    

    Here is the Makefile.in. I modified it a teeny bit, as per instructions. Here it is:

    #
    # Makefile.LINUX
    #
    #
    # If you compile, change the name to Makefile.in.
    #
    #
    
    #-----------------------------------------------------------------------------
    # Shell
    #-----------------------------------------------------------------------------
    
    SHELL = /bin/sh
    
    #-----------------------------------------------------------------------------
    # Platform
    #-----------------------------------------------------------------------------
    
    PLAT = LINUX
    
    #-----------------------------------------------------------------------------
    # Libraries and includes
    #-----------------------------------------------------------------------------
    
    BLLIB = ../lib/cblas_LINUX.a
    CBLIB = ../lib/cblas_$(PLAT).a
    
    #-----------------------------------------------------------------------------
    # Compilers
    #-----------------------------------------------------------------------------
    
    CC = gcc
    FC = gfortran
    LOADER = $(FC)
    
    #-----------------------------------------------------------------------------
    # Flags for Compilers
    #-----------------------------------------------------------------------------
    
    CFLAGS = -O3 -DADD_
    FFLAGS = -O3
    
    #-----------------------------------------------------------------------------
    # Archive programs and flags
    #-----------------------------------------------------------------------------
    
    ARCH = ar
    ARCHFLAGS = cr
    RANLIB = ranlib
    

    The line I modified here was

     BLLIB = ../lib/cblas_LINUX.a
    

    I just changed the path. And now there IS a cblas_LINUX.a in ../lib, so that is, I think, correct.

    Please, any pointers to why I am getting these errors would be really helpful. Isn't CBLAS supposed to be self-contained? Why does it even show such undefined references?

    Thank you for reading and for any suggestions!

  • Admin
    Admin almost 2 years
    Well, I did find it useful! Thanks!