Menu

Compiling Elk on an M1 Mac - Issues with OpenBLAS

Elk Users
Vivek
2024-03-25
2025-05-16
  • Vivek

    Vivek - 2024-03-25

    I'm trying to compile Elk 9.5.1 on a MacBook Pro M1 Max running macOS 14.4. My make.inc is attached. The relevant uncommented part of make.inc is

    #-------------------------------------------------------------------------------
    # GNU Fortran compiler with OpenBLAS, LAPACK and FFTW
    F90 = mpif90
    F90_OPTS = -Ofast -march=native -mtune=native -fopenmp -ffpe-summary=none -Wno-lto-type-mismatch
    F90_LIB = -lopenblas -llapack -lfftw3 -lfftw3f
    SRC_OBLAS =
    #-------------------------------------------------------------------------------
    

    OpenMPI, Libomp, breLAPACK, OpenBLAS and FFTW are all installed using homebrew.

    When I run make, I get the following trailing error message:

    ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc'
    **ld: library 'openblas' not found**
    collect2: error: ld returned 1 exit status
    make[1]: *** [elk] Error 1
    make: *** [all] Error 2
    

    My LDFLAGS and CPPFLAGS variable definitions in ~/.zshrc read like so:

    export LDFLAGS="-L/opt/homebrew/opt/lapack/lib -L/opt/homebrew/opt/openblas/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/lapack/include -I/opt/homebrew/opt/openblas/include"
    

    I have also tried to install OpenBLAS in my own path, and change the LDFLAGS and CPPFLAGS to point to that local installation (as opposed to the Homebrew one), to no avail.

    The problem may be OpenBLAS-specific, but there doesn't seem to be any useful workaround on the internet for this issue. Any leads will be highly appreciated. Thanks in advance.

     
  • J. K. Dewhurst

    J. K. Dewhurst - 2024-03-25

    Hi Vivek,

    Unfortunately, I don't have access to a MacBook. However you could try installing the static libraries, copying them to the elk/src directory and linking with

    F90_LIB = libopenblas.a liblapack.a
    

    Regards,
    Kay.

     
  • Vivek

    Vivek - 2024-03-25

    Hi Kay, thanks for the tip. I think I was able to get it to work after installing static libraries not just for OpenBLAS and LAPACK but also FFTW3.

    F90_LIB = libopenblas.a liblapack.a libfftw3.a libfftw3f.a
    

    Thanks indeed for your help!

     
    • Mohamed Elhanoty

      Hi, could you please share the final make.inc file that you used. I can not compile elk on the M4 chip and I tried many things but nothing worked.

      here is the last error i got
      ld: library 'System' not found
      collect2: error: ld returned 1 exit status
      make[1]: *** [elk] Error 1
      make: *** [all] Error 2

       

Log in to post a comment.

MongoDB Logo MongoDB