Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28602 Discussions

"undefined symbol" when linking LAPACK

jordimp1
Beginner
677 Views
Hi,

I am trying to compile a Fortran90 code (grid4.f90) that requires two subroutines from LAPACK: geevx and syevx. When I compile my code with the attached Makefile, it gives an "undefined symbol" error for both of them.

I built a makefile (attached file "Makefile") following the examples in the User Guide for Intel MKL for Mac OS*X. When I use the Makefile22 file (attached), it gives a warning: "warning #10147: no action performed for specified file(s)". Further, it gives the above mentioned error. The full output is:
[bash]ifort -c -O2 grid4.f90 \
	-L/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t -I/opt/intel/Compiler/11.1/080/Frameworks/mkl/include -I/opt/intel/Compiler/11.1/080/Frameworks/mkl/include/em64t -I/opt/intel/Compiler/11.1/080/Frameworks/mkl/include/em64t/lp64 -lmkl_lapack95_lp64 \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_intel_lp64.a /opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_sequential.a \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_core.a \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_intel_lp64.a /opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_sequential.a \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_core.a
ifort: warning #10147: no action performed for specified file(s)
ifort -O2 -o grid4 grid4.o ana.o mapping.o bes_spl.o fundcst.o string.o \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_intel_lp64.a /opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_sequential.a \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_core.a \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_intel_lp64.a /opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_sequential.a \
	/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t/libmkl_core.a
Undefined symbols:
  "_geevx_", referenced from:
      _sum_and_diag_opt_ in grid4.o
  "_syevx_", referenced from:
      _sum_and_diag_ in grid4.o
ld: symbol(s) not found
make: *** [grid4] Error 1[/bash]

I understood the warning was because I was trying to compile only (-c option) when supplying at the same time library files *.a . Therefore, I modified the makefile to Makefile (also attached). Now there is no warning, but the "undefined symbol" error persists. The output is:
[bash]ifort -O2 -o grid4 grid4.o ana.o mapping.o bes_spl.o fundcst.o string.o \
	-L/opt/intel/Compiler/11.1/080/Frameworks/mkl/lib/em64t -I/opt/intel/Compiler/11.1/080/Frameworks/mkl/include -I/opt/intel/Compiler/11.1/080/Frameworks/mkl/include/em64t -I/opt/intel/Compiler/11.1/080/Frameworks/mkl/include/em64t/lp64 \
	-lmkl_lapack95_lp64 \
	-lmkl_intel_lp64 -lmkl_lapack -lmkl_sequential -lmkl_core
Undefined symbols:
  "_geevx_", referenced from:
      _sum_and_diag_opt_ in grid4.o
  "_syevx_", referenced from:
      _sum_and_diag_ in grid4.o
ld: symbol(s) not found
make: *** [grid4] Error 1[/bash]
Could any one give me some hint as to how to properly link the LAPACK libraries to my code?

I work on a Mac (version 10.6.8) and the ifort version I use is 11.1. I have added these two lines to my .bash_profile file to ensure all required environment variables are defined:
source /opt/intel/Compiler/11.1/080/bin/ifortvars.sh intel64
source /opt/intel/Compiler/11.1/080/Frameworks/mkl/tools/environment/mklvarsem64t.sh

Thanks.
0 Kudos
2 Replies
TimP
Honored Contributor III
677 Views
Your result leads to the suspicion that you tried to use lapack95 functions without the corresponding USE files. The generic lapack95 function names are to be resolved into specific lapack functions at compile time by use of the generic machinery, not at link time.
0 Kudos
jordimp1
Beginner
677 Views
Thank you, TimP. I have added the USE statements, and I also added
source /opt/intel/Compiler/11.1/080/bin/ifortvars.sh intel64
to my initialization script as it seems some environment variables were not properly defined.
Now the code compiles nicely with a Makefile containing:
[bash]F90=ifort
OPT=-C -O2 -heap-arrays -i-static -traceback
MKLPATH=$(MKLROOT)/lib/em64t
MKLINCLUDE=$(MKLROOT)/include
F95ROOT=/opt/intel/Compiler/11.1/080
LAPACKDIR=/opt/intel/Compiler/11.1/080/Frameworks/mkl/interfaces/lapack95/lib95/lib/em64t


grid4:  grid4.o ana.o mapping.o bes_spl.o fundcst.o string.o
        $(F90) $(OPT) -o grid4 grid4.o ana.o mapping.o bes_spl.o fundcst.o string.o 
        -I$(F95ROOT)/include/intel64/lp64 -L$(LAPACKDIR) -lmkl_lapack95_lp64 
        -L$(MKLPATH) -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core[/bash]
(Without -heap-arrays I run into segmentation fault as I use rather large matrices that don't fit into my RAM.)
0 Kudos
Reply