Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan4
Beginner
69 Views

static link

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 Kudos
7 Replies
Andrey_G_Intel2
Employee
69 Views

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
Dan4
Beginner
69 Views

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.


Andrey_G_Intel2
Employee
69 Views

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

Dan4
Beginner
69 Views

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.
Gennady_F_Intel
Moderator
69 Views

you can find this binaries into/opt/intel/Compiler/11.1/072/lib/intel64.
--Gennady
Dan4
Beginner
69 Views

Yes I can! But how can I statically link them? I have also used "-lguide" but it didn't help!

Andrey_G_Intel2
Employee
69 Views

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
Reply