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

static link

Dan4
初学者
1,654 次查看
Hi all,

I am trying to link my code statically. The code is dynamically compiled and works fine by the linking options below:

MKL = "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_intel_lp64.so "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_intel_thread.so "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_core.so -L"~/intel/Compiler/11.1/064/mkl/lib/em64t" -liomp5 -lpthread -lm -DMKL_Complex16="std::complex" -static-intel

Now I tried the line below to get static code:

MKL = "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_intel_lp64.a "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_intel_thread.a "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_core.a "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_solver_lp64.a -L"~/intel/Compiler/11.1/064/mkl/lib/em64t" -openmp -lpthread -lm -DMKL_Complex16="std::complex" -static-intel

and when I use above linking, I get many unresolved referenced to almost all MKL functions I have used. Is there anything wrong with the link above? Is it also possible to just provide the path, so the compiler can statically bind all libraries needed? I read somewhere that using "-static-intel" would do such thing, but it didn't help.

Thanks,

D.
0 项奖励
7 回复数
Andrey_G_Intel2
1,654 次查看
Hello danltu.se!

you forgot to use -Wl,--start-group/-Wl,--end-group linker options. So, your link line will look:
MKL = "-Wl,--start-group ~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_intel_lp64.a "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_intel_thread.a "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_core.a "~/intel/Compiler/11.1/064/mkl/lib/em64t"/libmkl_solver_lp64.a -Wl,--end-group -L"~/intel/Compiler/11.1/064/mkl/lib/em64t" -openmp -lpthread -lm -DMKL_Complex16="std::complex" -static-intel

Andrey
0 项奖励
Dan4
初学者
1,654 次查看
Thanks Andrey, when I compile with the link you said I still get this error:

error while loading shared libraries: libguide.so: cannot open shared object file: No such file or directory

should I still add more libraries to be linked?

Thanks,

D.


0 项奖励
Andrey_G_Intel2
1,655 次查看

danltu.se,

is it link error or you see this message then you are running your application?
Could you provide full link line, compiler version, os name and version?

Andrey

0 项奖励
Dan4
初学者
1,654 次查看
Hi,

No, I see this error when I run my application. I use Linux and Intel C++ compiler. I also used the link you provided in your previous post.

Thanks,

D.
0 项奖励
Gennady_F_Intel
主持人
1,654 次查看
you can find this binaries into/opt/intel/Compiler/11.1/072/lib/intel64.
--Gennady
0 项奖励
Dan4
初学者
1,654 次查看
Yes I can! But how can I statically link them? I have also used "-lguide" but it didn't help!

0 项奖励
Andrey_G_Intel2
1,655 次查看
danltu.se,

compiler shouldn`t put dependencies to libguide to your application. Looks like this dependency is coming from somewhere else (for example, from third-party libs which you are using in your application). Could you provide FULL link line?

Andrey
0 项奖励
回复