Wav files support different encodings, including mp3. Is there a C/C++ library that would produce mp3-encoded wav files from uncompressed wav? If not, what would be the best place to start to implement one?
The best way indead to use Lame (if you do not afraid patent issues). You can use the both sources for lame and lame_enc.dll. Using the lame_enc.dll is more easier. As for RIFF-WAV container: it is simply to create RIFF-WAV files according to RIFF-WAV specification.
There are another possibilities. For example using ACM codecs.
But in any case you should be capable to prepend sound stream with RIFF-WAV header. This can be done manaully (I think the simplest way) or by using some free library (it seems libsnd is capable to do this).