working solution.  compilation to be checked on a linux system.