help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Creating a library that uses GSL library functions


From: Brijesh Upadhaya
Subject: [Help-gsl] Creating a library that uses GSL library functions
Date: Tue, 11 Sep 2018 11:03:55 +0300

Hi,

I want to create a library .so that includes routines from GSL library. I
wrote the make file, everything works but when I try to list dynamic
dependencies using 'ldd' then I don't see any linkage to the library
(neither GSL):

#===============================================================================
# Makefile
# Build either static or shared library containing gsl routines
# Want to create libjam.so

DESTDIR=./
PREFIX=../lib
INCH=../include

AR=ar
CC=gcc
ANSIC=
DBG=-g
OPT=-O2
INLN=-DHAVE_INLINE
CIN=-I. -I/usr/local/include/gsl
SHRD=shared

ifeq ($(ANSIC),ansic)
PEDANT=-ansi -pedantic -W
else
PEDANT=-W
endif

ifeq ($(SHRD),shared)
SHFLAG=-fPIC
else
SHFLAG=
endif

CCFLAGS=$(PEDANT) -Wall -Wextra -Wconversion $(SHFLAG) \
    -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings \
    -Wstrict-prototypes -fshort-enums -fno-common -Wmissing-prototypes \
    -Wnested-externs $(DBG) $(INLN) -std=c11 $(OPT) $(CIN)

LIBS=-L/usr/local/lib -lgsl -lgslcblas -lm

ifeq ($(SHRD),shared)
ALIB=libjam.so
else
ALIB=libjam.a
endif

SRC=$(wildcard *.c)
OBJS=$(SRC:.c=.o)

ifeq ($(SHRD),shared)
$(ALIB): $(OBJS)
     $(CC) $(CCFLAGS) -shared $(OBJS) -o $@ $(LIBS)
else
$(ALIB): $(OBJS)
     $(AR) rcs $@ $^
endif

%.o: %.c
    $(CC) $(CCFLAGS) -c $< -o $@

clean:
    rm -f $(ALIB)
    rm -f a.out *.o *.mod

.PHONY: install
install: $(ALIB)
    cp -p $(ALIB) $(DESTDIR)$(PREFIX)
    cp *.h $(DESTDIR)$(INCH)

.PHONY: uninstall
uninstall:
    rm -f $(DESTDIR)$(PREFIX)/$(ALIB)
    rm -f $(DESTDIR)$(INCH)/*.h
#================================================================================

Any help would be great

Kind regards,
Brijesh


reply via email to

[Prev in Thread] Current Thread [Next in Thread]