Important: Please read the Qt Code of Conduct -

How to link Qt 2.4.1(32) with Intel MKL lib?

  • I use win8x64, Qt 2.4.1 (32 bit) and I can't use Intel MKL library. All .pro lines that i used did not work.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you sure your are using Qt 2 ?

    What error do you get ?

  • I'm sorry, that was Qt creator 2.4.1 I meant. I wanted to launch example with matrix multiplication it was ok with includes. But compiler said "no reference to mkl_alloc". I wrote LIBS+= full path to the first lib file and so on for all the lib files for 32. It was compiled ok, but if executed app failed "because there is no mkl_thread.dll". But I mentioned it in pro file

  • Lifetime Qt Champion

    You need to add the path to the folder where the dll resides in run environment PATH variable

  • I will post extra info later. Thanks)

  • Hi! I'm sorry, I've not stated the problem right. I have such a main.c file:
    @#define min(x,y) (((x) < (y)) ? (x) : (y))

    #include <stdio.h>
    #include <stdlib.h>
    #include "mkl.h"

    /* Consider adjusting LOOP_COUNT based on the performance of your computer /
    to make sure that total run time is at least 1 second */
    #define LOOP_COUNT 10

    int main()
    double *A, *B, *C;
    int m, n, p, i, j, k, r;
    double alpha, beta;
    double sum;
    double s_initial, s_elapsed;

    printf ("\n This example measures performance of rcomputing the real matrix product \n"
            " C=alpha*A*B+beta*C using a triple nested loop, where A, B, and C are \n"
            " matrices and alpha and beta are double precision scalars \n\n");
    m = 2000, p = 200, n = 1000;
    printf (" Initializing data for matrix multiplication C=A*B for matrix \n"
            " A(%ix%i) and matrix B(%ix%i)\n\n", m, p, p, n);
    alpha = 1.0; beta = 0.0;
    printf (" Allocating memory for matrices aligned on 64-byte boundary for better \n"
            " performance \n\n");
    A = (double *)mkl_malloc( m*p*sizeof( double ), 64 );
    return 0;

    It includes mkl.h file and uses only one mkl function: mkl_malloc().

    I used
    This utility helps to make a link line for different compilers. So I've chosen MSVC in Tools-Preferences Microsoft Visual C++ Compiler 12.0 (x64) and clicked Apply and OK. Then I used link advisor and wrote such a .pro file:
    @TEMPLATE = app
    CONFIG += console
    CONFIG -= qt

    SOURCES += main.c

    INCLUDEPATH += C:\mkl\include
    LIBS += "C:\mkl\lib\mic\libmkl_scalapack_ilp64.a"
    LIBS += "C:\mkl\lib\mic\libmkl_cdft_core.a"
    LIBS += "C:\mkl\lib\mic\libmkl_intel_ilp64.a"
    LIBS += "C:\mkl\lib\mic\libmkl_core.a"
    LIBS += "C:\mkl\lib\mic\libmkl_sequential.a"
    LIBS += "C:\mkl\lib\mic\libmkl_blacs_intelmpi_ilp64.a"

  • And there were such errors:
    C:\Users\Daniel\cholesky\mkl\main.c:65: error: undefined reference to `MKL_malloc'
    :-1: error: collect2: ld returned 1 exit status

  • Lifetime Qt Champion

    Just to sum up, you did get it building and running in 32bit and now you've changed the architecture and it doesn't build ?

  • Well, at first I just want to know what is the main approach to linking to libs. You see, I have three folders in lib-folder of MKL: "ia32", "intel64" and "mic". In "mic" I have .a files and .so files, mostly it's the same, but some of .so files don't have corresponding pair. Next, in ia32 there are only .lib files like mkl_core.lib, but strange thing, some of them have corresponfing file, it looks like this: mkl_core.lib and next to it mkl_core_dll.lib.
    And at last, in intel64 I have the same thing, names are different from those in ia32 but some og intel64\ files also have a pair mkl_core.lib and mkl_core_dll.lib and so on. And some of files are called like this: mkl_lapack95_ilp64.lib and mkl_lapack95_lp64.lib and so on.
    So, what files should I add to LIBS var and how.
    Thank you for quick answers!!)

  • Lifetime Qt Champion

    Then you need to choose the libraries that matches both your architecture and compiler.

    Since you already had the 32bit build working reuse the same files but from the intel64 folder.

    Also ensure that the compiler used is also the 64bit

  • As far as I can judge I use 32 bit compiler. And I use it in 64 bit Windows and that's the problem? I'll be grateful if you could tell me how to switch to appropriate compiler (considering I'm a newby)).

  • Oh, and I've never got anything compiled with mkl. My first post was a little desperate and erroneous). One time it was built but did not ran because of mkl_thread.dll not being found on my computer. Programm emitted that error message, but the point is that there is no such dll. There is only mkl_thread_dll.lib and I was't sure I understood this error clearly. And anyway I don't remember what link lines I used that time so that's not what I really want to know. I just want to understand (if possible) what's the conventional and understandable way of arranging libraries and linking to them afterwards, and how to apply such a useful knowledge to this case.

  • And referring to last but one post, I think I'll manage switching to msvc compiler 64 bit. And assuming I'll do it, what will be next?

  • And do I get it right that to switch to another compiler in Qt Creator I should have it all recompiled with this compiler?

  • OK, now I've downloaded Qt 5.1.1 msvc2012_64_opengl, and managed to accomplish configuring a kit with MSVC 2012 compiler and Qt 5.1.1 profile. But I have a problem with nmake. I've pointed it to Qt Creator when configuring compiler settings (because neither detected compiler nor detected kit didn't work). And every attempt ends up with make errors. It can't find iostream:
    fatal error C1083: ЌҐ г¤ Ґвбп ®вЄалвм д ©« ўЄ«о祭ЁҐ: iostream: No such file or directory
    I don't know what to do with its encoding but that's not the main trouble

  • Lifetime Qt Champion

    Are you sure you've got MSVC 2012 installed properly ?

  • Well, I've just downloaded VS express 2013 for Desktop. Of course I'm not sure, but today I downloaded jom and the same occured. I think problem is with cl.exe but I don't know how to configure it. And by the way, I'm not sure it's 64bit. My kit and compiler settings:

  • If russian interface confuses you please ask for translation

  • I've just tried to compile main.cpp with cl.exe with options that adds Qt Creator.

  • I've just tried to compile main.cpp with cl.exe with options that adds Qt Creator.
    @#include <iostream>
    using namespace std;

    int main()
    int a;
    cout << "Hello wr!\n";
    return 0;

    cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -I"..........\Qt\Qt5.1.1\5.1.1\msvc2012_64_opengl\mkspecs\win32-msvc2012"
    And it works just fine and produces obj file, the problem is aparrently with LINK. Because if I erase -c option (to get cl invoke linker after compiling) LINK emits error message, he can't open msvcprtd.lib

  • OK, now I can compile such an example with the same compile command line and with following link command line:
    "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe"
    /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib"
    /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86"
    And that's it. But I don't know what to do with nmake or jom, how do I change their compile and link lines, to make them behave like the above example? Any help would be appreciated.

  • Lifetime Qt Champion

    If you have installed VS it should be detected by Qt Creator so you should be able to do everything from it.

Log in to reply