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

undefined reference to dgemm_ and other functions

arthur_amarra
Beginner
4,105 Views
I'm compiling a program that uses LAPACK and BLAS routines, but I keep getting errors about not being able to find the references.

The code compiles properly to .o files, but linking produces the following errors:

Schur_st.o: In function `eigen_schur_':
Schur_st.f:(.text+0x126b): undefined reference to `dgemm_'
Schur_st.f:(.text+0x1517): undefined reference to `dgemm_'
Schur_st.o: In function `normeigenvector_.':
Schur_st.f:(.text+0x1de8): undefined reference to `dnrm2_'
Schur_st.f:(.text+0x1e07): undefined reference to `dnrm2_'
Schur_st.f:(.text+0x1e3f): undefined reference to `dscal_'
Schur_st.f:(.text+0x1e57): undefined reference to `dscal_'
Schur_st.f:(.text+0x1ed0): undefined reference to `idamax_'
Schur_st.f:(.text+0x1f27): undefined reference to `drot_'
...
/opt/intel/mkl/9.1.021/lib/32/libmkl_lapack.so: undefined reference to `slartv'
/opt/intel/mkl/9.1.021/lib/32/libmkl_lapack.so: undefined reference to `zscal'
/opt/intel/mkl/9.1.021/lib/32/libmkl_lapack.so: undefined reference to `zhpr'
/opt/intel/mkl/9.1.021/lib/32/libmkl_lapack.so: undefined reference to `zgeru'
/opt/intel/mkl/9.1.021/lib/32/libmkl_lapack.so: undefined reference to `ssyrk'
/opt/intel/mkl/9.1.021/lib/32/libmkl_lapack.so: undefined reference to `ssyr2k'


....and so on

My linker command is:

localhost src # ifort -L/opt/intel/mkl/9.1.021/lib/32 -static-intel -lmkl_ia32 -lmkl_lapack -lguide *.o -o SIMILAR-linux

and environment variables are:

LIBRARY_PATH=/opt/intel/mkl/9.1.021/lib/32
FPATH=/opt/intel/mkl/9.1.021/include
LD_LIBRARY_PATH=/opt/intel/mkl/9.1.021/lib/32:/opt/intel/fc/10.0.023/lib:/opt/intel/fc/10.0.023/lib
CPATH=/opt/intel/mkl/9.1.021/include
INCLUDE=/opt/intel/mkl/9.1.021/include


advice would be much appreciated.
0 Kudos
2 Replies
arthur_amarra
Beginner
4,105 Views
After changing the order of the link command (-lmkl_lapack going before -lmkl_ia32) the errors have reduced, but all DSS_ functions are still unresolved:

localhost src # ifort -L/opt/intel/mkl/9.1.021/lib/32 -static-intel -lmkl_lapack -lmkl_ia32 -lguide *.o -o SIMILAR-linux


MTXINIOP.f:(.text+0xc39): undefined reference to `dss_create_'
MTXINIOP.f:(.text+0xc71): undefined reference to `dss_define_structure_'
MTXINIOP.f:(.text+0xc98): undefined reference to `dss_define_structure_'
MTXINIOP.f:(.text+0xcba): undefined reference to `dss_define_structure_'
MTXINIOP.f:(.text+0xce1): undefined reference to `dss_reorder_'
MTXINIOP.f:(.text+0xd0c): undefined reference to `dss_factor_real_'
MTXINIOP.f:(.text+0xeb1): undefined reference to `dss_solve_real_'
MTXINIOP.f:(.text+0xf24): undefined reference to `dss_delete_'
MTXINIOP.f:(.text+0xf56): undefined reference to `dss_factor_real_'
....
and so on.

MTXINIOP.f has the line "use mkl_dss" and compiles to .o properly, but as you can see linking is a problem.

regards,
Arthur
0 Kudos
TimP
Honored Contributor III
4,105 Views
You should link *.o before the libraries, so that all unreferenced symbols are seen before libraries are searched. Sorry about not pointing it out before.
0 Kudos
Reply