Thanks your suggestion solved the problem. First I removed the semicolon (;) after &cpstream and I added the following code:
#define FKG_FORCED_USAGE 1
#include <sphelper.h>
#undef FKG_FORCED_USAGE
After this I added
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
to the beginning of main. Now my solution compiles and produces a wav file.