# Undefined reference to pardiso\_ with Intel MKL (oneAPI toolkit)

**URL:** <https://calculix.discourse.group/t/undefined-reference-to-pardiso-with-intel-mkl-oneapi-toolkit/373>\
**Category:** Uncategorized\
**Created:** [December 31, 2020, 2:02am UTC](https://calculix.discourse.group/t/undefined-reference-to-pardiso-with-intel-mkl-oneapi-toolkit/373 "2020-12-31T02:02:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manny9808](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/manny9808/32/143_2.png) [@manny9808](https://calculix.discourse.group/u/manny9808)\
**Post date:** [December 31, 2020, 2:02am UTC](https://calculix.discourse.group/t/undefined-reference-to-pardiso-with-intel-mkl-oneapi-toolkit/373/1 "2020-12-31T02:02:31Z")

</div>

Hello,

Has anyone faced error with MKL Pardiso? What worked for you? I tried the Feacluster makefile too but it didnt help. I have been trying to compile ccx with the Intel MKL Pardiso bt get following error:

```
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_factor':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:296: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_solve':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:333: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_cleanup':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:359: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_solve':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:333: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_cleanup':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:359: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso_as.o):/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso_as.c:161: more undefined references to `pardiso_' follow
collect2: error: ld returned 1 exit status
Makefile:49: recipe for target 'ccx_PardisoMKL_gcc' failed
make: *** [ccx_PardisoMKL_gcc] Error 1

```

**My makefile is as follows:**  
OPT = -g -O3  
CFLAGS = -Wall (OPT) -fopenmp -DARCH="Linux" -DARPACK -DPARDISO -DMATRIXSTORAGE -DUSE\_MT=1 -DMKL\_ILP64 -I{MKL\_INCLUDE} FFLAGS = -Wall (OPT) (OPTIONS) -I(MKL\_INCLUDE) -fopenmp

```
#ARPACK
#CFLAGS+= -I ../../../ARPACK -DARPACK

#BLAS and LAPACK
#CFLAGS+= -llpack -lblas

CC=gcc
FC=gfortran

OPTIONS = -w -fno-second-underscore -fcray-pointer -x f77-cpp-input
FPPSTOP= -x none

#INTEL MKL
MKL_LIB = /opt/intel/oneapi/mkl/2021.1.1/lib/intel64
MKL_INCLUDE=/opt/intel/oneapi/mkl/2021.1.1/include
CMPLR_PATH = /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64

.c.o :
        $(CC) $(CFLAGS) -c $<
.f.o :
        $(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.17.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)

LIBS= ../../../ARPACK/libarpack_UBUNTU.a -lpthread -lm -lc

ccx_PardisoMKL_gcc: $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LIBS)
        ./date.pl; $(CC) $(CFLAGS) -c ccx_2.17.c; \
        $(FC) $(OPT)p $(FFLAGS) -o $@ $(FPPSTOP) $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LIBS)
        -Wl,--start-group \
        $(MKL_LIB)/libmkl_intel_ilp64.a \
        $(MKL_LIB)/libmkl_intel_thread.a \
        $(MKL_LIB)/libmkl_core.a \
        $(MKL_LIB)/libmkl_blacs_openmpi_ilp64.a \
        -Wl,--end-group \
        -L$(CMPLR_PATH) -liomp5 -lpthread -lm -ldl

ccx_PardisoMKL_gcc.a: $(OCCXF) $(OCCXC)

```

Many thanks.

---

<div class="post-metadata">

**Author:** ![jbr](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jbr](https://calculix.discourse.group/u/jbr)\
**Post date:** [December 31, 2020, 11:01pm UTC](https://calculix.discourse.group/t/undefined-reference-to-pardiso-with-intel-mkl-oneapi-toolkit/373/2 "2020-12-31T23:01:24Z")

</div>

Hi @manny9808, shouldn’t you be using `CC=mpiicc` / `CC=icc` and `FC=mpiifort` / `FC=ifort`? Or can they be mixed?

---

<div class="post-metadata">

**Author:** ![manny9808](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/manny9808/32/143_2.png) [@manny9808](https://calculix.discourse.group/u/manny9808)\
**Post date:** [January 1, 2021, 11:36am UTC](https://calculix.discourse.group/t/undefined-reference-to-pardiso-with-intel-mkl-oneapi-toolkit/373/3 "2021-01-01T11:36:33Z")

</div>

Hello,  
icc and ifort are intel compilers. I wanted to use GNU compilers, hence gcc and gfortran.

I managed to get my makefile to work (added below for record).While I am not sure what made it work, I made following changes: upon installation of intel library, ran

> ./varsh.sh intel64

in env directory in installation; then in makefile

> $(LDFLAGS) before $(LIBS)

and

> “space” before -Wl

(threw me error if not done).

Makefile:

```
OPT = -g -O2
CFLAGS = -Wall $(OPT) -fopenmp -DARCH="Linux" -DARPACK -DPARDISO -DMATRIXSTORAGE -DUSE_MT=1 -DMKL_LP64 -I{MKL_INCLUDE}
FFLAGS = -Wall $(OPT) $(OPTIONS) -I$(MKL_INCLUDE) -fopenmp

#ARPACK
#CFLAGS+= -I /usr/local/ARPACK -DARPACK

#SPOOLES
#CFLAGS+= -I /usr/local/SPOOLES.2.2 -DSPOOLES

#BLAS and LAPACK
#CFLAGS+= -llpack -lblas

CC=gcc
FC=gfortran

OPTIONS = -w -fno-second-underscore -fcray-pointer -x f77-cpp-input
FPPSTOP= -x none

#INTEL MKL
MKL_LIB = /opt/intel/oneapi/mkl/2021.1.1/lib/intel64
MKL_INCLUDE=/opt/intel/oneapi/mkl/2021.1.1/include
CMPLR_PATH = /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64 

.c.o :
	$(CC) $(CFLAGS) -c $<
.f.o :
	$(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.15.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)

LIBS= ../../../ARPACK/libarpack_UBUNTU.a -lpthread -lm -lc

ccx_PardisoMKL_gcc: $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LDFLAGS) $(LIBS)\
        ./date.pl; $(CC) $(CFLAGS) -c ccx_2.15.c; \
        $(FC) $(OPT)p $(FFLAGS) -o $@ $(FPPSTOP) $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LDFLAGS) $(LIBS)\
         -Wl,--start-group \
        $(MKL_LIB)/libmkl_gf_lp64.a \
        $(MKL_LIB)/libmkl_gnu_thread.a \
        $(MKL_LIB)/libmkl_core.a \
        $(MKL_LIB)/libmkl_blacs_openmpi_lp64.a \
         -Wl,--end-group \
        -L$(CMPLR_PATH) -lgomp -lpthread -lm -ldl

ccx_PardisoMKL_gcc.a: $(OCCXF) $(OCCXC)
	ar vr $@ $?
clean:
	rm *.a *.o ccx_PardisoMKL_gcc

```

I am getting significant gains in computation vs SPOOLES, still, the gain in multithreading for pardiso is not where I want it to be. For simple cantilever with 200k hex elements:

 ![image](https://global.discourse-cdn.com/free1/uploads/calculix/original/1X/c2cfe11188c541d7b3f53197ce8a7c9c99198d68.png)

Hence,I will be looking to compile with MPI.
