From: Kian Wright Date: 2005-05-04T12:39:47+09:00 Subject: C Extensions using MingW (invalid address LoadError) Hi I've had some real trouble getting my first C extensions for Ruby to link correctly, and now they won't load into Ruby properly. 1) How to correctly compile and link extensions using the mingw gcc compiler? It looks like extconf.rb is configured for MSVC, not gcc. So I played with it and managed to at least get it to compile and link. But what are the correct options? This is what I used: gcc -mno-cygwin -DNT -D__MSVCRT__ -Os -IC:/bin/ruby/lib/ruby/1.8/i386-mswin3 2 \ -IC:/Projects/Ruby/proj1/src/lib/c -I./.. -I./../missing \ -c -TcRbColorUtils.c -o RbColorUtils.o RbColorUtils.c gcc -Lc:/bin/ruby/lib -nostartfiles -mdll --target=mingw32 --export-all -de f:RbColorUtils-i386-mswin32.def \ -o RbColorUtils.so RbColorUtils.o rgbhsi.o msvcrt-ruby18.lib 2) Why doesn't my extension load? Calling it using "ruby -e "require './RbColorUtils'" gives the following error: ./RbColorUtils.so: 487: Attempt to access invalid address. - ./RbColorUtils.so (LoadError) from c:/bin/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require' from -e:1 3) Can I even do this? Can I produce a DLL with MingW/gcc and use it in the standard Ruby Windows exe distro, which I assume is compiled with MSVC? Any ideas would be greatly appreciated. There doesn't appear to be much documentation on producing extensions except with MSVC. Kian Wright