How to make a makefile using specific libraries in different ways?

The problem I am facing is that I need to compile my code using specific libraries located in different places of the path. I need to use the -lncurses library from the path. / ramdisk / libs, the problem is that this directory also contains a version of the lthr library that I don’t want to link. The make file pulls both libraries from the same place, which is not what I want. I cannot change the contents of these library directories on the file system, so I need to find a way to tell the Makefile to link the lncurses library to circuit A and to link the lthr library from path B, instead using lthr from path A.

Any suggestions?

CC=icc
NCE=-L./ramdisk/libs
CFLAGS+=-I$(ROOTDIR)/../../include
#LDFLAGS=-static -lthr 

$(DESTDIR)/nce: nce
        mkdir -p $(DESTDIR)
        $(INSTALL) -m 777 nce $(DESTDIR) 

nce: nce.c 
        $(CC) $(CFLAGS) nce.c $(LDFLAGS) -o nce -lthr $(NCE) -lncurses
+3
2

() , . -lncurses ./ramdisk/libs/libncurses.a ( - ). , , , , , , .

[]

lib, , - :

CC=icc
THR=/full/path/to/wherever/libthr/lives
NCE=/full/path/to/ramdisk/libs
CFLAGS+=-I$(ROOTDIR)/../../include
LDFLAGS=-static

nce: nce.c
    $(CC) $(CFLAGS) nce.c $(LDFLAGS) -o nce -L$(THR) -W,-rpath=$(THR) -lthr -L$(NCE) -W,-rpath=$(NCE) -lncurses

, icc, , , , ramdisk, .

+2

.

ncurses , thr .

+1

Source: https://habr.com/ru/post/1720916/


All Articles