Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

How to link the MKL with Xcode?

paladinchin
Beginner
1,875 Views
I tried to compile the following codes with Xcode 3.1.2 using MKL 10.1

---------------------------------------

program copy_main

implicit none

real x(10), y(10)

integer n, incx, incy, i

n = 3

incx = 3

incy = 1

do i = 1, 10

x(i) = i

end do

call scopy (n, x, incx, y, incy)

print*,'Y=',(y(i),i=1,n)

end program

---------------------------------------


I've set the "Header Search Paths" to/opt/intel/Compiler/11.0/064/Frameworks/mkl/Headers ,

"Library Search Paths" to/opt/intel/Compiler/11.0/064/Frameworks/mkl/Libraries/em64t , and

"Other Linker Flags" to-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread .


But warnings occurred as following, can anyone help me solve this problem? Thanks a lot.

warning #11009: file format not recognized for /opt/intel/Compiler/11.0/064/Frameworks/mkl/Libraries/em64t/libmkl_intel_lp64.dylib

warning #11009: file format not recognized for /opt/intel/Compiler/11.0/064/Frameworks/mkl/Libraries/em64t/libmkl_core.dylib

warning #11009: file format not recognized for /opt/intel/Compiler/11.0/064/Frameworks/mkl/Libraries/em64t/libmkl_intel_thread.dylib





0 Kudos
1 Solution
Ying_H_Intel
Employee
1,875 Views
Quoting - paladinchin
Thanks for your kindness.
But the article doesn't help at all.
I've done everything the manual wrote.

Hi paladinchin

It looks the compiler version is for 32bit application in your Xcode and is for 64bit application in your command line enviroment.

In command line, could you please try the command?
$ ifort -V
ifort -V
Intel Fortran Compiler Professional for applications running on Intel 64, Version 11.0 Build 20081105 Package ID: m_cprof_p_11.0.056
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.

If it show " running on Intel 64", thenthe compileris supposed for 64bit application.

Whatkind ofapplication do you want to build?
You caneither
to change the compiler to32bit compilerby command
$source /opt/intel/Compiler/11.0/056/bin/ifortvars.sh ia32
(my test is 056 version, youcan change to 064)

or change the library to 64bit library
$ifort dot.f90 -L/opt/intel/Compiler/11.0/056/Frameworks/mkl/lib/em64t/ -I$INCLUDE -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread

In Xcode enviroment, ifLibrary not loaded,the library path is not in search path of Xcode environment. Please add DYLD_LIBRARY_PATH environment variable in the Xcode environment. here isaexample


Or
You may try tolink static MKLlibraryfirst , for example,in Other Linker Flags,
add/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_intel.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_intel_thread.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_core.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_intel_thread.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_core.a
/opt/intel/Compiler/11.0/056/lib/libiomp5.a
(Please notes, libiomp5.* were locatedin Compiler lib directory).

and see if it works.

Best Regards,
Ying

View solution in original post

0 Kudos
11 Replies
Gennady_F_Intel
Moderator
1,875 Views

You need to check what compiler you are using.
It seems that you are trying to compile 64-bit binaries by using 32-bit compiler and it may the cause of the problem. 32-bit libraries cannot be linked against 64-bit binaries.
/gif

0 Kudos
paladinchin
Beginner
1,875 Views

You need to check what compiler you are using.
It seems that you are trying to compile 64-bit binaries by using 32-bit compiler and it may the cause of the problem. 32-bit libraries cannot be linked against 64-bit binaries.


Thanks a lot. Those warnings disappeared after I set everything to 32-bit.
But now here comes a new problem, the Debugger Console window shows the message:

dyld: Library not loaded: libmkl_intel.dylib
Referenced from: /Users/adamchin/Documents/Projects/dot/build/Debug/dot
Reason: image not found

The Debugger has exited due to signal 5 (SIGTRAP).The Debugger has exited due to signal 5 (SIGTRAP).


Please help me.


0 Kudos
Gennady_F_Intel
Moderator
1,875 Views

Have the environment variables set up properly?
Please check your environment variables.
First of all, please check - LD_LIBRARY_PATH.
/gif

0 Kudos
paladinchin
Beginner
1,875 Views

Have the environment variables set up properly?
Please check your environment variables.
First of all, please check - LD_LIBRARY_PATH

I've checked the environment variable by typing

"echo $LD_LIBRARY_PATH"

in the terminal window, and it returned

"LD_LIBRARY_PATH: Undefined variable."

I set thoseenvironment variablesby typing

"./mklvars32.sh" and "./mklvars32.csh"

and it seemed to fail.

Could someone tell me how to set the environment variables?

Thanks a lot.
0 Kudos
Gennady_F_Intel
Moderator
1,875 Views
source mklvars32.sh
/gif

0 Kudos
paladinchin
Beginner
1,875 Views
source mklvars32.sh

Thank you, Gennady.
After I typed the command, I checked two environment variables first.

WLAN99-240:dot adamchin$ echo $LIBRARY_PATH
/opt/intel/Compiler/11.0/064/Frameworks/mkl/lib/32:/opt/intel/Compiler/11.0/064/Frameworks/mkl/lib/32

WLAN99-240:dot adamchin$ echo $INCLUDE
/opt/intel/Compiler/11.0/064/Frameworks/mkl/Headers:/opt/intel/Compiler/11.0/064/Frameworks/mkl/Headers

Then I executed the following

WLAN99-240:dot adamchin$ ifort dot.f90 -L$LIBRARY_PATH -I$INCLUDE -lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread

but it returned the message:

ld warning: in /opt/intel/Compiler/11.0/064/Frameworks/mkl/lib/32/libmkl_intel.dylib, file is not of required architecture
ld warning: in /opt/intel/Compiler/11.0/064/Frameworks/mkl/lib/32/libmkl_intel_thread.dylib, file is not of required architecture
ld warning: in /opt/intel/Compiler/11.0/064/Frameworks/mkl/lib/32/libmkl_core.dylib, file is not of required architecture
Undefined symbols:
"_scopy_", referenced from:
_MAIN__ in ifortObGRkN.o
ld: symbol(s) not found

Did I make any mistake?
By the way, could you tell me how to set environment variables inside Xcode?



0 Kudos
Gennady_F_Intel
Moderator
1,875 Views

Ops, i've forget that the original question was related the Xcode ( the previous response was about command line ).I am apologizing for that.
I think the article:" Compiling and linking MKL with Xcode*" http://software.intel.com/en-us/articles/intel-math-kernel-library-for-mac-os-compiling-and-linking-with-xcode/
should helps you to do all settings for linking MKL into Xcode development environment
--Gennady

0 Kudos
paladinchin
Beginner
1,875 Views

Ops, i've forget that the original question was related the Xcode ( the previous response was about command line ).I am apologizing for that.
I think the article:" Compiling and linking MKL with Xcode*" http://software.intel.com/en-us/articles/intel-math-kernel-library-for-mac-os-compiling-and-linking-with-xcode/
should helps you to do all settings for linking MKL into Xcode development environment
--Gennady

Thanks for your kindness.
But the article doesn't help at all.
I've done everything the manual wrote.
0 Kudos
Ying_H_Intel
Employee
1,876 Views
Quoting - paladinchin
Thanks for your kindness.
But the article doesn't help at all.
I've done everything the manual wrote.

Hi paladinchin

It looks the compiler version is for 32bit application in your Xcode and is for 64bit application in your command line enviroment.

In command line, could you please try the command?
$ ifort -V
ifort -V
Intel Fortran Compiler Professional for applications running on Intel 64, Version 11.0 Build 20081105 Package ID: m_cprof_p_11.0.056
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.

If it show " running on Intel 64", thenthe compileris supposed for 64bit application.

Whatkind ofapplication do you want to build?
You caneither
to change the compiler to32bit compilerby command
$source /opt/intel/Compiler/11.0/056/bin/ifortvars.sh ia32
(my test is 056 version, youcan change to 064)

or change the library to 64bit library
$ifort dot.f90 -L/opt/intel/Compiler/11.0/056/Frameworks/mkl/lib/em64t/ -I$INCLUDE -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread

In Xcode enviroment, ifLibrary not loaded,the library path is not in search path of Xcode environment. Please add DYLD_LIBRARY_PATH environment variable in the Xcode environment. here isaexample


Or
You may try tolink static MKLlibraryfirst , for example,in Other Linker Flags,
add/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_intel.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_intel_thread.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_core.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_intel_thread.a
/opt/intel/Compiler/11.0/056/Frameworks/mkl/32/libmkl_core.a
/opt/intel/Compiler/11.0/056/lib/libiomp5.a
(Please notes, libiomp5.* were locatedin Compiler lib directory).

and see if it works.

Best Regards,
Ying
0 Kudos
paladinchin
Beginner
1,875 Views
Hi, Ying Hu
Your advice does help me with the problem and my program works well.
Truly thanks.
I also appreciate the comments given by Gennedy, thanks.
Now another problem hits me when I try to use lapack in Fortran 95 syntax.

The following program works when Fortran 77 syntax is used:

program main

implicit none

integer, parameter :: n = 2

integer :: ilo, ihi, lda=n, lwork=n, info, ii

real*8 :: a(n,n), ao(n,n), work(n), tau(n)

ilo=1

ihi=n

a(1,1)=1

a(1,2)=2

a(2,1)=4

a(2,2)=5

ao=a


call dgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)

call dorghr(n, ilo, ihi, a, lda, tau, work, lwork, info)

write(*,*) ao

write(*,*) a

end program


But if I call the following subroutines instead

call gehrd(a, tau ,ilo ,ihi,info)

call orghr(a, tau ,ilo ,ihi ,info)


a warning occurs:symbol(s) not found


Please tell me if I forget any linking steps.

Thank you.




0 Kudos
paladinchin
Beginner
1,875 Views
Hi, Ying Hu
Your advice does help me with the problem and my program works well.
Truly thanks.
I also appreciate the comments given by Gennedy, thanks.
Now another problem hits me when I try to use lapack in Fortran 95 syntax.

The following program works when Fortran 77 syntax is used:

program main

implicit none

integer, parameter :: n = 2

integer :: ilo, ihi, lda=n, lwork=n, info, ii

real*8 :: a(n,n), ao(n,n), work(n), tau(n)

ilo=1

ihi=n

a(1,1)=1

a(1,2)=2

a(2,1)=4

a(2,2)=5

ao=a


call dgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)

call dorghr(n, ilo, ihi, a, lda, tau, work, lwork, info)

write(*,*) ao

write(*,*) a

end program


But if I call the following subroutines instead

call gehrd(a, tau ,ilo ,ihi, info)

call orghr(a, tau ,ilo ,ihi ,info)


a warning occurs:symbol(s) not found


Please tell me if I forget any linking steps.

Thank you.




0 Kudos
Reply