Finish porting lib and add a sample.