My Makefile was like this earlier.
export SOURCE1 = source1.c \
1.c \
2.c \
3.c
export SOURCE2 = source2.c \
1.c
all:
gcc -Wall -W -g -O2 ${SOURCE1} -lm -lipc -o source1
gcc -Wall -W -g -O2 ${SOURCE2} -lm -lipc -o source2
This one works fine. And, I wanted to create a shared object which comprises 1.c, 2.c and 3.c. Consequently I changed my Makefile to
export LIB_SOURCE 1.c 2.c 3.c
export SOURCE1 = source1.c
export SOURCE2 = source2.c
all:
gcc -Wall -W -g -O2 ${LIB_SOURCE} -o libsrc.so.1
ln -sf libsrc.so.1 libsrc.so.0
ln -sf libsrc.so.0 libsrc.so
gcc -Wall -W -g -O2 ${SOURCE1} -lm -lipc -lsrc -o source1
gcc -Wall -W -g -O2 ${SOURCE2} -lm -lipc -lsrc -o source2
The make failed while compiling source2, saying it
src.so: undefined reference to 'var1'
The var1 is defined in 3.c which is not needed by source2. Since it's included in the library it's failing looking at it. How to move on with this error.
Thanks,