0

I'm new to Linux OS. And I'm trying to run the code which download from http://cbio.mskcc.org/leslielab/software/string_kernels.html And I compile the ./src file which is in the ./profkernel using a makefile. However, when I run make , I get the following error: screenshot

And the makefile looks like this

# MITRA MakeFile


ifeq ($(MODE),debug)
    #Debug flags
    COMPFLAGS =  -c -g -pg -Wall
    CC = cc
    CLIBS = -lm -g -pg
else 
    ifeq ($(MODE),memwatch)
    #Memwatch flags
    COMPFLAGS = -DMEMWATCH -DMW_STDIO -c -g -Wall -pg
    CC = cc
    CLIBS = -DMEMWATCH -DMW_STDIO -lm  -g -Wall -pg
else
    #Efficient Flags
    COMPFLAGS = -c -O3 
    CC = cc
    CLIBS = -lm  -O3
endif
endif

INCLUDES = HashTable.h mitra.h MiscUtil.h SymbolTable.h SymbolTable.h   Globals.h  Input.h



string-kernel   : string-kernel.o HashTable.o MiscUtil.o SymbolTable.o Globals.o  Input.o memwatch.o
${CC} ${CLIBS} -o  string-kernel string-kernel.o HashTable.o MiscUtil.o  SymbolTable.o Globals.o  Input.o memwatch.o

%.o : %.c
${CC} ${COMPFLAGS} $< -o $@

TAGS  :
     etags *.c *.h

clean :
     rm string-kernel *.o

I notice there are similar questions. And I have tried to add same words from those answers like

LDFLAGS=-lm or LDLIBS=-lm

but it didn't work. Does anybody know? Thanks very much

Alisa W
  • 19
  • 4
  • hope this is already answered just add ```CC=gcc CFLAGS=-Wall LDFLAGS=-lm``` check this http://stackoverflow.com/questions/13249610/how-to-use-ldflags-in-makefile – Ankanna Mar 26 '16 at 10:32
  • I have tried this ,but it doesn't work. Maybe its because our code are different. Anyway, thanks – Alisa W Mar 26 '16 at 12:46

1 Answers1

0

-l options (which are in ${CLIBS} in this Makefile) should come after object files that use them, not before. Otherwise the link will fail whan the static libs are used or, as in this case, when the linker has --as-needed enabled by default (e.g. in Ubuntu). So

${CC} -o  string-kernel string-kernel.o HashTable.o MiscUtil.o  SymbolTable.o Globals.o  Input.o memwatch.o ${CLIBS}
wRAR
  • 25,009
  • 4
  • 84
  • 97