Fixed compilation issues with newer versions of gcc

In recent versions of gcc, the linking flags must be specified after
enumerating the object files or else these flags will be ignored.