[TynesideLUG] making the shared object file...

Ian Bruntlett ian.bruntlett at gmail.com
Sat Apr 2 12:15:23 UTC 2022


*makefile...*
// inc-dec.h
extern int increment(int old_value);
extern int decrement(int old_value);
ian at t
CPPFLAGS= -fPIC -g
OBJECTS=increment.o decrement.o
TARGET=libinc-dec.so
LDFLAGS= -shared

libinc-dec.so : increment.o decrement.o
$(CC) $(CFLAGS) $(OBJECTS) -o $@ $(LDFLAGS)

.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET)

*header file...*
// inc-dec.h

*decrement.c*
// decrement.c - function for libinc-dec.so

extern int decrement(int old_value)
{
  return old_value - 1;
}

*increment.c*
// increment.c - function for libinc-dec.so

extern int increment(int old_value)
{
  return old_value + 1;
}
-- ACCU - Professionalism in programming - http://www.accu.org
-- My writing - https://sites.google.com/site/ianbruntlett/
-- Free Software page -
https://sites.google.com/site/ianbruntlett/home/free-software


More information about the Tyneside mailing list