getopt is not in scope

This PR fixes issue #170.
I just implemented the fix described in this issue, so it works in some cases, but maybe not for all.