You must put the libraries where the compiler can find them. Though you can put the libraries in any directory and point the compiler towards it using make files, that is rarely followed.
For rpm's, it automatically installs in the required directory.
For any programming in linux, this book is the bible :
Advanced Linux Programming
You'll find all the answers to your queries if you read that book
.