Here is an example of how to build a shared library on FreeBSD of some object files, and then build an executable of some other object files, and finally link them together.
This Makefile has been tested with BSD make.
This example comes with no source code. It is just an example how to use compiler and linker flags to create a shared library on FreeBSD.
Note specially the following lines:
With these compiler/linker flags, there is no need to use environment variables such as LD_LIBRARY_PATH.
These flags can be ignored if a library will be installed in one of the standard paths /lib/, /usr/lib/, or /usr/local/lib/, but during development and testing of a library, it is recommended to use an alternative path to not mix them with possible existing older versions of the same library.
In this case, DEFAULT_LIB_INSTALL_PATH is set to the same path as the executable.