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

compiling errors using dcsrilu0()

mhuang05
Beginner
374 Views

I use the ILU-preconditional BiCGStab to solve a sparse nonsymmetric linear system on a single core. I employ the funciton dcsrilu0() to create a preconditioner. But I got the following error message when I complied my code:

undefined reference to `dcsrilu0_'

I guess I must miss some links. I write my makefile like

*************************************************

CC = mpicc
CFLAGS = -Wall -g
Includes =-I/opt/intel/mkl/10.2.1.017/include
LFLAGS = -L/opt/intel/mkl/10.2.1.017/lib/em64t
LIBS =-lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lmkl_solver_lp64 -lmkl_intel_lp64 -Wl,--start-group -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread -lm -lmpi

srcs1 = BiCGStab_OneCore.c mmio.c
objs1 = $(srcs1: .c=.o)

prog1 = bicgstabOneCore


srcs = $(srcs1)
objs = $(objs1)
progs = $(prog1)

all : $(progs)

$(prog1): $(objs1)
$(CC) $(CFLAGS) $(Includes) $(LFLAGS) $(LIBS) -o $@ $^

.c.o:
$(CC) $(CFLAGS) $(Includes) -c $<

clean:
$(RM) -rf *.o $(progs)

*******************************************************************************

I am just wondering what's wrong with this makefile. Thanks.

Min
0 Kudos
1 Solution
Vladimir_Koldakov__I
New Contributor III
374 Views

Hi,

Try this line - prerequisites before libs:


$(CC) $(CFLAGS) $(Includes) $(LFLAGS) $^ $(LIBS) -o $@

Thanks,
Vladimir

View solution in original post

0 Kudos
4 Replies
TimP
Honored Contributor III
374 Views
2nd attempt to post reply:
Are you mixing up the advice for static and dynamic linking?
If you static link, but don't put all the necessary libraries inside the begin ... end group, and specify full paths, you will see such errors.
If you link dynamic libraries, you should require the begin...end qualifiers.
Please try adhering more closely to the advice in the link advisor, on the right column of forum header page.
If you are running on a single core, there's no point in linking the thread and OpenMP libraries, rather than sequential.
0 Kudos
mhuang05
Beginner
374 Views
Quoting - tim18
2nd attempt to post reply:
Are you mixing up the advice for static and dynamic linking?
If you static link, but don't put all the necessary libraries inside the begin ... end group, and specify full paths, you will see such errors.
If you link dynamic libraries, you should require the begin...end qualifiers.
Please try adhering more closely to the advice in the link advisor, on the right column of forum header page.
If you are running on a single core, there's no point in linking the thread and OpenMP libraries, rather than sequential.

Thanks for your reply.

I tried the MKL link line advisor and was given the following suggested link line:

-L$MKLPATH $MKLPATH/libmkl_solver_lp64_sequential.a -Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread

So I modified my makefile as follows:

LIBS = /opt/intel/mkl/10.2.1.017/lib/em64t/libmkl_solver_lp64_sequential.a -Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread

But, still I got the same error message. Also, if I use static link, it's even worse.

Btw, the reanson I linked the thread and OpenMP is that I previously compiled my sequential programs and parallel programs simultaneously and the makefile worked fine. At that time, I called functions in lapack, scalapack, blacs
and there was no problem.



0 Kudos
Vladimir_Koldakov__I
New Contributor III
375 Views

Hi,

Try this line - prerequisites before libs:


$(CC) $(CFLAGS) $(Includes) $(LFLAGS) $^ $(LIBS) -o $@

Thanks,
Vladimir

0 Kudos
mhuang05
Beginner
374 Views

Hi,

Try this line - prerequisites before libs:


$(CC) $(CFLAGS) $(Includes) $(LFLAGS) $^ $(LIBS) -o $@

Thanks,
Vladimir


Hi Vladimir,

I just modified my makefile according to your suggestion. It works now!!!
Thank you so much.

Min
0 Kudos
Reply