Our simple library code:
- hello.c
- hello.h
Our test client code which uses the library :
- client.c
The process is as followed:
gcc -c -Wall -fpic hello.c
generates a object filehello.o
gcc -shared -o libhello.dylib hello.o
creates the shared librarymv libhello.dylib /usr/local/lib
moves the libaray to one of the standard dynamic load paths.gcc client.c -o /tmp/hello_client -lhello
compiles the client code.
Then you can run the client code by /tmp/hello_client
and it will print out "hello form C".