C\C++ open source PCM to Mp3 convertor/encoder?
What do I need
You are after LAME, which is available in both library and executable form.
As for examples, you will have to consult that project's documentation.
This links give information about basic functions required for encoding using LAME API
LAME API