How to compile and run a simple program in C using MKL in linux
I have tried googling and searching the answer on this site, but to no avail. I am a beginner in linux as well as MKL, but I can compile and run programs in linux (not using MKL) fine. Intel's manual is a tad too technical for me, I cant understand if i have to link statically, dynamically, and with what options......
now the problems and doubts: 1. Is the program itself fine ? 2. How do I compile it? I read about long link commands for this and the intel's link advisor (and the manual), tried them as it is, but they dont work. 3. If I simply write "icc exp4.c", where exp4.c is the name of the program, I get the error:-
/usr/include/gnu/stubs.h(7): catastrophic error: could not open source file "gnu/stubs-32.h" # include ^
compilation aborted for exp4.c (code 4) what is this error ?
4. If I compile by gcc, which I guess I shouldnt/cant, but still.... I get
/tmp/ccCqahjj.o: In function `main': exp4.c:(.text+0x53): undefined reference to `cblas_sasum' collect2: ld returned 1 exit status
We can recommend you to read the User's Guide first of all.
- after that please see at the examples which you can find into the package.For example the similar test you can find in ..\ComposerXE-2011\mkl\examples\cblas\source\ directoty ( on windows, but on linux it would be the similar folder).
-Please see the cblas_sasumx.c example.You can find there the makefiles which you can use for building these examples also.
- how to link with MKL? there are several KB articles, but first we recomend to see how to link with MKL - these article in the case if your version is 10.*
Code that contains calls to special libraries, such as MKL, needs to be linked with these libraries in addition to the standard C and system libraries. This is done either by specifying compiler options, configuration files or simply by specifying the special library in the linker command.
Depending on the version of Linux and MKL, the command can be as simple as
icc -mkl xcblas.c
with the help of the MKL Link Line Advisor Tool, with suitable choices for your setup,
It finally worked after I tried to understand what the huge link line was about, and after being more comfortable with linux commands. I have a different problem now, which I suppose I should ask in a different thread.