Resolve some errors that occur when compiling examples using g++

Suggestion by Jeremia Bär.