Reputation: 794
I am trying to statically link mkl into assembly code, with the following:
ld -L/home/ziheng/intel/compilers_and_libraries/linux/mkl/lib/intel64 -L /home/ziheng/intel/compilers_and_libraries/linux/lib/intel64/ -lm -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lmkl_blacs_openmpi_ilp64 -liomp5 -lpthread -ldl bump.o
It shows that I have undefined reference to: puts@@GLIBC_2.2.5
Does anyone know what flag I am missing?
Upvotes: 0
Views: 1302
Reputation: 213686
This command:
ld -L/home/ziheng/intel/compilers_and_libraries/linux/mkl/lib/intel64 -L /home/ziheng/intel/compilers_and_libraries/linux/lib/intel64/ -lm -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lmkl_blacs_openmpi_ilp64 -liomp5 -lpthread -ldl bump.o
is incorrect on every platform that GIBC supports.
In general, user-level code should never link anything directly with ld
-- always use appropriate compiler driver (likely gcc
here).
In addition, putting libraries before object files on the link line will fail with most unix linkers (at least for archive libraries).
Correct command would be something like this:
gcc bump.o \
-L/home/ziheng/intel/compilers_and_libraries/linux/mkl/lib/intel64 \
-L/home/ziheng/intel/compilers_and_libraries/linux/lib/intel64 \
-lmkl_intel_lp64 -lmkl_blacs_openmpi_ilp64 -lmkl_intel_thread -lmkl_core \
-liomp5 -lm -lpthread -ldl
P.S.
What library is puts@@GLIBC_2.2.5 in
It's in libc
.
P.P.S.
I am trying to statically link mkl
There is nothing on your command line that implies static linking. You'll need to add -static
for that.
Upvotes: 3