If it is about cplex (see https://en.wikipedia.org/wiki/CPLEX ):
get the software bundle - including the libraries (binaries) for your compiler and OS and follow the documentation about installation/use.
Having installed the libraries correctly, you have already 'added' them to your compiler. Then - as Peter Breuer already stated - you have to include the appropriate header files to be able to call the functions contained in the libraries.
To add optimization libraray such as cplex to c++ you need a copy of the library written in c++ or an equivalent compiled reloadable assembly language library.
If you have it in c++ then you have to include it in the compiler step.
If you have it in compiled assembly code then you have to call in the c++ runtime step.
The library might be a compiled binary file that can attached with a link command.
If you are already committed to a specific library like cplex, I suggest you look on their FAQ or installation instructions. If you are not already committed to a specific library, you might have a look at CERES developped by Google and made open-source a few years ago. It has automatic differentiation capabilities (not finite difference approximation of the derivatives) and is very well maintained!