Linking against libraries using GCC
In this recipe, we will learn how to link a program to an external library, both one that's installed system-wide and one that resides in our home directory. Before we can link to a library, however, we need to create it. This is also something that we are going to cover in this recipe. Knowing how to link against libraries will enable you to make use of a wide variety of ready-to-use functions. Instead of writing everything by yourself, you can use libraries that are already available. Often, there is no need to reinvent the wheel, thus saving you a lot of time.
Getting ready
For this recipe, you'll only need what's listed under the Technical requirements section of this chapter.
How to do it…
Here, we will learn how to link against both a shared library installed on your system and a library from your home directory. We will begin with a library already on your system: the math library.