Link Copied
When you use static linking, and you list one or more .o objects after one or more static libraries that contain symbols needed by the object(s), the linking will fail. See, for example, the explanation in http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking/ .
The solution is quite simple: list the names of the .o files to be linked before the list of libraries in the command that invokes the linker ld. In your makefile, you should have something similar to:
[bash]
icpc -static ./src/TestMath.o -L/opt/intel/composer_xe_2013.1.117/mkl/lib/ia32 -mkl=sequential -o "TestMath"
[/bash]
static linking of MKL has the additional problem of circular dependencies which has to be resolved by --start-group ..... --end-group linker directives, and full path names of the libraries, as shown in the MKL link advisor http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
-mkl=sequential is a good idea for initial testing, but I think it may not work with -static.
Hello,
As mecej4 and Tim pointed out, one key is the order of linked library, another key is the -mkl and -static combination. Here is one KB talking about the problem:
http://software.intel.com/en-us/articles/link-error-when-static-linking-to-intel-mkl-on-linux-6
So the recommend static link line is
icpc -intel-static ./src/TestMath.o -L/opt/intel/composer_xe_2013.1.117/mkl/lib/ia32 -mkl=sequential -o TestMath
Best Regards,
Ying
Hi,
this simple Fortran90 program does not link statically with --mkl=sequential/parallel:
milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_mklpar_static/./mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -static-intel -mkl=sequential -O3 src/CMakeFiles/example.dir/example.f90.o -o bin/example src/CMakeFiles/example.dir/example.f90.o: In function `MAIN__': /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/src/example.f90:(.text+0x37a): undefined reference to `dgemm_' milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_mklpar_static/.
milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_mklpar_static/./mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -static-intel -mkl=parallel -O3 src/CMakeFiles/example.dir/example.f90.o -o bin/example src/CMakeFiles/example.dir/example.f90.o: In function `MAIN__': /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/src/example.f90:(.text+0x37a): undefined reference to `dgemm_'
Without -static-intel flag it works:
milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_mklpar_static/./mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -mkl=parallel -O3 src/CMakeFiles/example.dir/example.f90.o -o bin/example milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_mklpar_static/.bin/example PASSED
Any help ? I guess --mkl=<sequential/parallel/cluster> is intended with dynamical linking only. Comments please ?
For more complete information about compiler optimizations, see our Optimization Notice.