diff --git a/Rakefile.cross b/Rakefile.cross
index 4b9033e28d3378bd2c2bb7209dcd88b044af58c5..38fbdee93d8117c9cbd4733712dcd91c26c86a25 100644
--- a/Rakefile.cross
+++ b/Rakefile.cross
@@ -391,6 +391,7 @@ task :mingw32 do
     warn "Please refer to your distribution/package manager documentation about installation."
     fail
   end
+  ENV['CROSS_PREFIX'] = Rake::ExtensionCompiler.mingw_host
 end
 
 
diff --git a/ext/fox16/extconf.rb b/ext/fox16/extconf.rb
index 90091d3e0395a2309248b98f8317d0c78c59b849..6e5f66d0170b12cda5064159feed4316471cd0c7 100755
--- a/ext/fox16/extconf.rb
+++ b/ext/fox16/extconf.rb
@@ -79,7 +79,7 @@ def do_rake_compiler_setup
     have_library( 'opengl32' ) && append_library( $libs, 'opengl32' )
     have_library( 'winspool', 'EnumPrintersA') && append_library( $libs, 'winspool' )
 
-    CONFIG['CC'] += "\nCXX=i586-mingw32msvc-g++" # Hack CXX into Makefile for cross compilation
+    CONFIG['CC'] += "\nCXX=#{ENV['CROSS_PREFIX']}-g++" # Hack CXX into Makefile for cross compilation
     $CFLAGS += " -D_SYS_TIME_H_" # fix incompatible types for gettimeofday()
   elsif RUBY_PLATFORM =~ /mingw/
     $CFLAGS = $CFLAGS + " -I/usr/local/include"