how to rotate the measured acceleration value (x,y,z) with the quaternion (w,x,y,z)

I want to remove gravity value from acceleration. Form here i read that i need to rotate acceleration with respect to quaternion. Then we can subtract gravity value to get linear acceleration.

So i am looking for any help/suggestion to get linear acceleration. you can make any assumption and suggest some thing. I am working with c++ and openGL. And i am new in this.

Thanks