0

I need to just run the make command for makefile. But when I run this make command I get the error that "undefined reference to `log'" because I know this fact that it doesn't include math Library and we have to include at runtime. I know that if I run this using gcc comiler then i can write -lm at the end, it will include math library. My problem is I need to run it using make command that is- make lu.

In this if I write make lu -lm it is not linking math library. Please help

I have edited my make file

SHELL=/bin/sh
BENCHMARK=ep
BENCHMARKU=EP

include ../config/make.def

OBJS = ep.o ${COMMON}/c_print_results.o ${COMMON}/c_${RAND}.o \
       ${COMMON}/c_timers.o ${COMMON}/c_wtime.o

include ../sys/make.common
LDLIBS=-lm
LDFLAGS=-lm


${PROGRAM}: config ${OBJS}
    ${CLINK} ${CLINKFLAGS} -o ${PROGRAM} $(LDFLAGS) $(LOADLIBES) ${OBJS} ${C_LIB}


ep.o:       ep.c npbparams.h
    ${CCOMPILE} ep.c

clean:
    - rm -f *.o *~ 
    - rm -f npbparams.h core
user2963445
  • 9
  • 1
  • 3
  • Show us the command that works (without Make). – Beta Nov 07 '13 at 06:35
  • Command that works- gcc lu.c -lm. I have installed NAS parallel benchmarks and to run these benchmarks I have to run command- make lu – – user2963445 Nov 07 '13 at 07:35
  • i think this answers your question : http://stackoverflow.com/questions/13249610/how-to-use-ldflags-in-makefile Basically you need to use ldflags in makefile to link math lib at compile time – psych0der Nov 07 '13 at 07:39

1 Answers1

0

Put

LDLIBS=-lm

in your Makefile.

Claudio
  • 10,614
  • 4
  • 31
  • 71
  • I added the code given above but I'm still having same problem. Please Help. SHELL=/bin/sh BENCHMARK=ep BENCHMARKU=EP include ../config/make.def OBJS = ep.o ${COMMON}/c_print_results.o ${COMMON}/c_${RAND}.o \ ${COMMON}/c_timers.o ${COMMON}/c_wtime.o include ../sys/make.common LDLIBS=-lm LDFLAGS=-lm ${PROGRAM}: config ${OBJS} ${CLINK} ${CLINKFLAGS} -o ${PROGRAM} $(LDFLAGS) $(LOADLIBES) ${OBJS} ${C_LIB} ep.o: ep.c npbparams.h ${CCOMPILE} ep.c clean: - rm -f *.o *~ - rm -f npbparams.h core – user2963445 Dec 06 '13 at 17:43