Wow it really is like magic programming, or am I missing something here? You need to move the -lm flag to a specific place?
Does that also fix the GetEnv issue?