Port from c++ to C api to allow mingw and linux support?