extend cxxfunction by saving the dynamic shared objects