Hi folks!
I'm trying to build a (multi-file) sample program with a shared library for demonstration purposes. But unfortunately, I'm getting something wrong. Anybody here to help?
Code:
$ make
gcc -Wall -g -o mylib.o -c mylib.c
gcc -Wall -g -o libmylib.so -shared mylib.o
gcc -Wall -g -o prog -L. -lmylib wrapLibraryFunc.c prog.c
wrapLibraryFunc.c:4:6: warning: ‘wrapLibraryFunc’ defined but not used [-Wunused-function]
4 | void wrapLibraryFunc(char *message)
| ^~~~~~~~~~~~~~~
In file included from prog.c:1:
prog.h:1:13: warning: ‘wrapLibraryFunc’ used but never defined
1 | static void wrapLibraryFunc(char *message);
| ^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccg3TTFt.o: in function `wrapLibraryFunc':
/home/user/src/cprogramming/wrapLibraryFunc.c:6: undefined reference to `printMessage'
/usr/bin/ld: /tmp/ccpTloxp.o: in function `main':
/home/user/src/cprogramming/prog.c:5: undefined reference to `wrapLibraryFunc'
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: prog] Error 1