Fix compilation errors on casting and linking problem on librt