Search code examples
xcodelinkerosx-snow-leopardintelintel-mkl

Can't link Intel Math Kernel Library to Xcode because there is no Intel_MKL.framework folder


I'm trying to use the Intel Math Kernel Library (MKL) on a 64-bit Mac running Mac OSX 10.6.6 and Xcode 3.2.6. For Macs, Intel MKL is only available by installing the full Intel Composer XE 2011 C++ compiler. I have done so, and I run the bash scripts

/Developer/opt/intel/composer_xe_2011_sp1.6.038/mkl/bin/intel64/mklvars_intel64.sh
/Developer/opt/intel/composer_xe_2011_sp1.6.038/link_install.sh

to set environmental variables for Composer XE and MKL. I am able to use the compiler to build simple test projects in Xcode.

However, I am unable to use the MKL because I cannot link it in Xcode as described here. I don't have the MKL framework folder as described in that hyperlink

/Library/Frameworks/Intel_MKL.framework/

(To be specific, there is no folder titled Intel_MKL.framework anywhere on my system.) Checking to make sure this folder exists is mentioned in several MKL reference manuals from Intel, but no where do they tell you what to do if it doesn't exist! It seems to be assumed to exist if you've correctly installed MKL, but I have ("Composer XE installation successful") and there's no Intel_MKL.framework.

If it matters, the error I get is

"_dsyevx", referenced from:
jEigenvalues(TNT::Array2D<double>&, TNT::Array1D<double>&)in main.o 
ld: symbol(s) not found
collect2: ld returned 1 exit status

which I understand is consistent with not being properly linked.

I've spent a great bit of time and effort trying to get help, including the Intel forums, to no avail. I suspect this is a simple problem (I'm just an amateur).

Many thanks for any help.


EDIT:

At Paul's suggestion, I've re-run the installer, with no change. The only mkl.h file is located in

/Developer/opt/intel/composer_xe_2011_sp1.6.038/mkl/include 

as well as the expected identical copy in the non-Xcode installation directory

/opt/intel/composer_xe_2011_sp1.6.038/mkl/include

I don't know if this is what I'm supposed to list under "header search path" in Xcode, but I listed it long ago. I've also listed

/Developer/opt/intel/composer_xe_2011_sp1.6.038/mkl/lib 

as the "library search path", and I have added these linker flags based off of my best attempt at reading this 2011 guide:

-libmkl_intel_lp64.a 
-libmkl_core.a 
-libmkl_sequential.a 
-libmkl_intel_thread.a

Nothing has changed, and I get the same error:

ld returned 1 exit status

Could he problem be with dynamic vs. static linking? I chose static linking (.a endings rather than .dylib) because it seemed simpler, but I have no idea. Changing to dynamic didn't do anything.

Is there anyway to get feedback, here? I have no idea what to change based on this error.


EDIT2:

I just found an option "Use Intel Math Kernel Library" in the Xcode "Project info" (one of perhaps 100 options) which I had no idea existed. (Where am I supposed to find out about this?) Now things are building, but when I run the executable, I get

exit;
dyld: Library not loaded: libmkl_intel_lp64.dylib
  Referenced from: /Users/.../nameofexecutable
  Reason: image not found
Trace/BPT trap
logout

I've double checked that the library search directory is correct. I also tried switching over static libraries with .a endings, but the error was exactly the same. (Still had .dylib endings.) Does this mean I'm stuck with dynamic? Why? I also defined the variable

DYLD_LIBRARY_PATH

to be

/Developer/opt/intel/composer_xe_2011_sp1.6.038/compiler/lib: /Developer/opt/intel/composer_xe_2011_sp1.6.038/mkl/lib

as suggest in the old instructions here but nothing changed.

Wow, this is horribly difficult.


Solution

  • IMPORTANT EDIT

    What is wrote under this edit works at least when I run the executable "from XCODE". When I find the directory it is built in, and double click on it there, I receive this message :

    Last login: Sun Nov 24 17:05:19 on ttys002
    MacBook-Pro-de-totouser:~ totouser$ /Users/totouser/Library/Developer/Xcode/DerivedData/THECONSOLEAPPLICATION-hknajgycvjjcotdtkeeyxbzmtfty/Build/Products/Debug/THECONSOLEAPPLICATION ; exit;
    dyld: Library not loaded: libmkl_sequential.dylib
      Referenced from: /Users/totouser/Library/Developer/Xcode/DerivedData/THECONSOLEAPPLICATION-hknajgycvjjcotdtkeeyxbzmtfty/Build/Products/Debug/THECONSOLEAPPLICATION
      Reason: image not found
    Trace/BPT trap: 5
    logout
    

    [Process completed]

    If someone could help, that would be nice, because I am really stuck here

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Ok, I succeeded in doing what you wanted to do :

    I have installed m_ccompxe_2013_sp1.1.103 under mac os 10.8.5 64bits where I am using XCode 5.0.2.

    The first thing is to reference mkl include directory in the project. Before doing it, I would like stress that even after having done it, I was never able in c++ code to write something like this

    #include "mkl.h"
    

    and I was obliged to put the full path to the mkl.h file, which was a bit boring, as I want ideally to put like this :

    #include <mkl>
    #include <mkl_vsl.h>
    #include <mkl_vsl_functions.h>
    

    etc. So I found for instance the "iostream" file on my mac, copied it somewhere, modified the copy's name to mkl, and put the content of mkl.h (which is in "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include" on my mac) in it, save it in "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include", and I referenced the directory "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include" in the include directories of my xcode project. How did I do this ?

    I double clicked on "target", then on "build settings", then on "all", and searched for "search paths" menu. There

    1) in "header search path", debug and release, I put "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include" and "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include/intel64"

    2) in "library search path", debug and release I put "/opt/intel/composer_xe_2013_sp1.1.103/compiler/lib/intel64" and "/opt/intel/composer_xe_2013_sp1.1.103/compiler/lib" and "/opt/intel/composer_xe_2013_sp1.1.103/mkl/lib"

    Then I edited the "DYLD_LIBRARY_PATH" environment variable (only in my project) to make equal to "/opt/intel/composer_xe_2013_sp1.1.103/compiler/lib:/opt/intel/composer_xe_2013_sp1.1.103/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.1.103/mkl/lib". How did I do this ? I cliked on the name of my project icon at the immediate right next to the triangle and square buttons at the left of the upper bar, and then I clicked on "edit scheme" which opened a window, and then clicked on "run my project debug" in the left column of that window, and then I clicked on "Argument", went in "environment variables", and +'d a new variable called DYLD_LIBRARY_PATH with value

    /opt/intel/composer_xe_2013_sp1.1.103/compiler/lib:/opt/intel/composer_xe_2013_sp1.1.103/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.1.103/mkl/lib

    Bizarrly, this set it also for "run my project release", which was ok for me, but I still find this bizarre. Anyway.

    After this, I had to add command telling the compiler (LLVM 5, didn't modify anything related to this) to link to the libraries I was about to use :

    for this I double cliked back on "target", then went in "build settings", then in "all", and searched then for "other linker flags" where in debug and in release I put :

    -lmkl_sequential -lmkl_core -lmkl_intel_lp64 -lpthread -lmkl_intel_thread -liomp5

    Then In the main.cpp I put for instance :

    #include <iostream>
    // #include "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include/mkl.h"
    // #include "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include/mkl_vsl.h"
    // #include "/opt/intel/composer_xe_2013_sp1.1.103/mkl/include/mkl_vsl_functions.h"
    #include <mkl>
    #include <mkl_vsl.h>
    #include <mkl_vsl_functions.h>
    
    int main(int argc, const char * argv[])
    {
        VSLStreamStatePtr stream;
        vslNewStream(&stream, VSL_BRNG_SFMT19937, 777);
        double * pUNIF = new double [ 1000000 ] ;
        vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD_ACCURATE, stream, 1000000, pUNIF, 0.0, 1.0);
        vslDeleteStream(&stream);
        for (int i = 0 ; i < 100000 ; ++i )
        {
            std::cout << *(pUNIF+i) << std::endl;
        }
        std::cout << "END." << std::endl;
        getchar();
        return 0;
    }
    

    Then I built and ran, I everything was ok ;-)

    As would dear sir Malcolm Tucker say : "never easy, never f***** easy."

    Regards,

    MEF.