Community
cancel
Showing results for 
Search instead for 
Did you mean: 
zx123
Beginner
4,169 Views

error: mkl.h: No such file or directory

Jump to solution
Hi

I can't fix error in my makefile:

CPP=/opt/intel/Compiler/11.1/059/bin/ia32/icpc
INC=/opt/intel/Compiler/11.1/059/mkl/include/
LIB=/opt/intel/Compiler/11.1/059/mkl/lib/32/
main: main.cpp
$(CPP) -Wall -I$(INC) -c main.cpp
main: main.o
$(CPP) main.o -L$(LIB) -lmkl_intel -lmkl_core -lmkl_intel_thread -liomp5 -lpthread -lm -o main

Then I try to compile I always get error: mkl.h: No such file or directory. What is wrong?

The following script compiles correctly
#! /bin/bash
PATH_LIB="/opt/intel/Compiler/11.1/059/mkl/lib/32"
PATH_MKL="/opt/intel/Compiler/11.1/059/mkl/include/"
PATH_CPP="/opt/intel/Compiler/11.1/059/bin/ia32/"
LANG=C ${PATH_CPP}icpc main.cpp -I${PATH_MKL} -L${PATH_LIB} -static -lmkl_intel -lmkl_core -lmkl_intel_thread -liomp5 -lpthread -lm -o main
0 Kudos
1 Solution
Evgueni_P_Intel
Employee
4,169 Views

zx123,
Remember that by default make makes the target of the first rule (the tokens before the semicolon.)
Do make main instead of make or put the rule for main in front of the rule for main.o.
Good luck!

But... you may find running your application also tricky!
Your make file links your application to your dynamic MKL libraries.
For this reason, your application contains only references to the needed MKL libraries, functions, andvaribales.
These references are resolved only when you run your application.
At that moment, the linker needs to know the path to the MKL libraries because by default this path isn't hard-coded in your application.
The standard solution is to add the path to the MKL libraries to environment variable LD_LIBRARY_PATH as follows:
export LD_LIBRARY_PATH=/opt/intel/Compiler/11.1/059/mkl/lib/32/:${LD_LIBRARY_PATH}
Of course, this needs be done before you run the application.
Good luck once again!

-Evgueni.

View solution in original post

9 Replies
Evgueni_P_Intel
Employee
4,168 Views
Quoting - zx123
Hi

I can't fix error in my makefile:

CPP=/opt/intel/Compiler/11.1/059/bin/ia32/icpc
INC=/opt/intel/Compiler/11.1/059/mkl/include/
LIB=/opt/intel/Compiler/11.1/059/mkl/lib/32/
main: main.cpp
$(CPP) -Wall -I$(INC) -c main.cpp
main: main.o
$(CPP) main.o -L$(LIB) -lmkl_intel -lmkl_core -lmkl_intel_thread -liomp5 -lpthread -lm -o main

Then I try to compile I always get error: mkl.h: No such file or directory. What is wrong?

The following script compiles correctly
#! /bin/bash
PATH_LIB="/opt/intel/Compiler/11.1/059/mkl/lib/32"
PATH_MKL="/opt/intel/Compiler/11.1/059/mkl/include/"
PATH_CPP="/opt/intel/Compiler/11.1/059/bin/ia32/"
LANG=C ${PATH_CPP}icpc main.cpp -I${PATH_MKL} -L${PATH_LIB} -static -lmkl_intel -lmkl_core -lmkl_intel_thread -liomp5 -lpthread -lm -o main

Hi zx123!
I think that the target of the 1st rule should be main.o.
-Evgueni.
Evgueni_P_Intel
Employee
4,168 Views


...that is, the make file should look as follows:
main.o: main.cpp
$(CPP) -Wall -I$(INC) -c main.cpp
main: main.o
$(CPP) main.o -L$(LIB) -lmkl_intel -lmkl_core -lmkl_intel_thread -liomp5 -lpthread -lm -o main
zx123
Beginner
4,168 Views

Yes, it works!!!

Thank you, Evgueni
zx123
Beginner
4,168 Views
Sorry...Sure I'm not programmer...

I replaced main: main.cpp -> main.o: main.cpp
but now makefile creates main.o but I still have not an executable. My makefile does not produce executable file. What is wrong now?
Evgueni_P_Intel
Employee
4,168 Views
Quoting - zx123
Sorry...Sure I'm not programmer...

I replaced main: main.cpp -> main.o: main.cpp
but now makefile creates main.o but I still have not an executable. My makefile does not produce executable file. What is wrong now?

Your make file produces an executable called main -- this name is given after the -o switch at the end of the second rule.
Though this namedoesn'tendwith .exe, you can run the file.
-Evgueni.
zx123
Beginner
4,168 Views

Your make file produces an executable called main -- this name is given after the -o switch at the end of the second rule.
Though this namedoesn'tendwith .exe, you can run the file.
-Evgueni.

Unfortunately, an executable (indeed called main) is produced only if I use main: main.cpp instead of main.o: main.cpp and only if I exclude #include ''mkl.h'' from my code. If I unclude both main.o: main.cpp and #include ''mkl.h'' no any executables are produced - only main.o That is very strange...

Is it possible to compile code with mkl library using only one rule as in my script that I listed in my first post?
Evgueni_P_Intel
Employee
4,170 Views

zx123,
Remember that by default make makes the target of the first rule (the tokens before the semicolon.)
Do make main instead of make or put the rule for main in front of the rule for main.o.
Good luck!

But... you may find running your application also tricky!
Your make file links your application to your dynamic MKL libraries.
For this reason, your application contains only references to the needed MKL libraries, functions, andvaribales.
These references are resolved only when you run your application.
At that moment, the linker needs to know the path to the MKL libraries because by default this path isn't hard-coded in your application.
The standard solution is to add the path to the MKL libraries to environment variable LD_LIBRARY_PATH as follows:
export LD_LIBRARY_PATH=/opt/intel/Compiler/11.1/059/mkl/lib/32/:${LD_LIBRARY_PATH}
Of course, this needs be done before you run the application.
Good luck once again!

-Evgueni.

View solution in original post

zx123
Beginner
4,168 Views
yes, I understood

Thank you!
Subodh_P_
Beginner
4,168 Views

This error tends to happen if the paths for include headers and bindings are not set correctly. Intel has made this process very straightforward now. Just set the environment using following command for say intel64 architecture located at /opt/intel/bin.

source ./compilervars.sh intel64

This will set all the appropriate locations for MKL/TBB/etc headers. If you intent to set only the MKL paths then refer to bash script located at /opt/intel/mkl/bin named as "mklvars.sh"

Thanks,

Subodh Pachghare

www.thesubodh.com

Reply