Typically, your software will be installed either under /, or /usr, or /usr/local. This is called the "prefix". / is typically reserved for the most critical operating system programs. /usr/ is reserved for use by package managers. Therefore, when you write software, it is most polite to set it up so that the prefix will be /usr/local. Then this can be overridden when someone packages it for a distribution.
Notice I'm not specifically talking about "lib". There are several common subdirs under the prefix, lib being just one of them. "bin" is used for executables, "share" for data files, "lib" for shared libraries and so on. So if your program is a library, you can install it by default to /usr/local/lib. If it's a normal program, you can have it install to /usr/local/bin with your data files in /usr/local/share. The important thing is that you make it so the prefix is selectable at compile time. Some may prefer to install to /usr rather than /usr/local or vice-versa.