do I have to install (i.e. copy to a specific place, say, /usr/share/lib) this library?
No.
For a UNIX shared library, you need to arrange for two things:
- You have to make the library known to the static linker, while linking main executable. Usually this is achieved by adding
-L/path/to/directory -lfoo
link flags to the link line. - You have to make runtime loader search
/path/to/directory
as well. This is system-specific. On many systems, settingLD_LIBRARY_PATH
environment variable achieves the desired result, though this is usually not the preferred method. Another method is to encode this path into the application itself, e.g. on Linux one would add-Wl,-rpath=/path/to/directory
to the application link line.