Search code examples
c++qtqt-creatoropenblas

Linking OpenBLAS with Qt Creator project


I am using Qt Creator for development. I want to use Armadillo linear algebra library. Therefore I used following code in my pro file:

INCLUDEPATH += C:\armadillo-7.950.1\include

LIBS += \
    -LC:\armadillo-7.950.1\examples\lib_win64 \
    -llapack_win64_MT \
    -lblas_win64_MT

It was all good and the project compiled and linked properly. Next task was to replace LAPACK and BLAS with OpenBLAS. So the pro file was changed as following:

INCLUDEPATH += C:\armadillo-7.950.1\include \
           C:\OpenBLAS-v0.2.19-Win64-int32\include

LIBS += \
    -LC:\OpenBLAS-v0.2.19-Win64-int32\lib \
    -llibopenblas

Now I receive the error: LNK1104: cannot open file 'libopenblas.lib'. I have downloaded windows binary of OpenBLAS. The installed folder structure is as given in the image: installed OpenBLAS folder

Please let me know what is going wrong?

Thanks.


Solution

  • There are two reasons for this problem:

    1. Weird naming of .lib file as libopenblas.dll.a even though package is called windows binary.
    2. Incomplete binary package---- It doesn't contain all required dlls

    Solution:

    1. Choose a binary----win 64 or win32 and download it.

    2. rename libopenblas.dll.a as libopenblas.lib as Yuriy has suggested

    3. download from https://sourceforge.net/projects/openblas/files/v0.2.14/ required missing DLLs are bundled again under weirdly named zip files "mingw64_dll" or "mingw32_dll" depending upon the binary type which you have downloaded in step 1. These zip file contain "libgcc_s_seh-1.dll", "libgfortran-3.dll" and "libquadmath-0.dll"

    4. Add include and lib as I have done to your project and build with correct target depending upon your downloaded binary i.e win64 or X86

    5. Copy libopenblas.dll from bin folder of OpenBLAS binary and "libgcc_s_seh-1.dll", "libgfortran-3.dll", "libquadmath-0.dll" from "mingw64_dll" or "mingw32_dll" depending upon the binary type to build debug or release directory where the exe reside.

      1. Run your program and you are good to go.

      2. If you want to escape copying again and again set a required system environment variable for the path containing these DLLs