Code:
export LD_LIBRARY_PATH=./
This would blow out any other paths you might have in LD_LIBRARY_PATH. It's probably empty, but to be safe, you should do something like the following to prepend your custom library path to the beginning of LD_LIBRARY_PATH.
Code:
export LD_LIBRARY_PATH="./lib:${LD_LIBRARY_PATH}"
I haven't done shared library stuff in a while, so I'm not totally sure on this, but you may need to run ldconfig after you build your .so file. I think you're fine with a single make file, but we can clean it up a bit:
Code:
default: app/LAB5exe
lib/libRecursionapi.so: lib/DIV.o lib/MUL.o lib/EXP.o lib/GCD.o
gcc -shared -o $@ $^
ldconfig -n ./lib
app/LAB5exe: lib/LAB5.c lib/libRecursionapi.so
gcc lib/LAB5.c -L./lib -lRecursionapi -o app/LAB5exe -ldl
%.o : lib/%.c
gcc -fPIC -c $<
That's all done by hand, so there may be some small errors, but it should be more or less what you want.
That ldconfig sets up the necessary symlinks for shared libraries. Check the man page for more details.
The $@ refers to the name of the target.
The $^ refers to all prerequisites for that rule.
The % acts like a wildcard character, and whatever fills it in on the left side of the colon also fills it in on the right side. So %.o expands in one case to DIV.o, which depends on lib/DIV.c. It does likewise for MUL.o, EXP.o and GCD.o.
The $< refers to the name of the first prerequisite for that rule (e.g. lib/DIV.c).
Make files can be a bit scary, but once you get over the fear, their kinda cool And the online help is pretty good: GNU `make'.