[libxml-devel] Release and Windows Gem

Charlie Savage cfis at savagexi.com
Fri Feb 8 18:31:48 EST 2008


> Oh? Hmm... I'm just going by what I've read others doing --cross
> compiling on Linux using mingw. I'm not sure at all about actually
> compiling on a WIndows platform, since I don't use Windows at all.

I haven't tried that - you have some links I can look at?

Just to be a bit more clear about the issues on Windows - the problem is 
that all the library and directory information that extconf.rb pulls 
from the Config::CONFIG (which is compiled into the Ruby executable) is 
hard-coded for the original compiler.  On Windows that is VC++6, so 
MingW can't work with extconf.rb. The opposite is also true, if the Ruby 
executable is built with MingW then extconf.rb won't work with VC++6.

   Ruby needs something like Python's DistUtils, which support for
>> using various different compiles.
> 
> That would be nice, of course. But I imagine that's a whole additional
> level of heavy involvement. Ultimately it would be great to add this
> level of functionality to Reap. 

Oh definitely - wasn't suggesting doing it.  Just dreaming.  Someone 
should just go take DistUtils and do a direct port to Ruby and be done 
with it.

> If that's the case, it might be possible right now.
> 
>   $ reap-make
> 
> That's the same as running extconf.rb and then make by hand. The only
> thing substantially missing is building binary packages. That
> shouldn't be too hard though, as it basically means setting the
> platform field and not doing a full distclean before packaging.

> Or am I missing something?

You need to call the correct make program (make vs nmake), link to the 
right libraries, set up the correct include paths, etc.  Also, what 
about the depedency on libxml?  How would that work in a cross-compiled 
environment?

> Yea, I'm not sure. I haven't really tested it. I simply read of others
> doing it and their examples. Basically it requires re-compiling ruby
> itself with mingw, and from there supposedly one can make it work.

So...I think it could be quite hard getting this working in a 
cross-compiler environment, but I've never tried so don't know.

To show how we do it with ruby-prof, I've included below the rakefile we 
use.  The requirements are having Ruby installed, MinGW and msys.

ruby-prof also includes a VC++ 2005 project file, which also works fine. 
  The reason we don't use it to distribute the ruby-prof.dll though is 
to avoid the dependency on the VC++ 2005 runtime files.  And that raises 
another interesting question - libxml for Windows is compiled with the 
Windows XP DDK (http://www.zlatkovic.com/libxml.en.html) - and I'm not 
sure what VC++ version that is.


Charlie


# We can't use Ruby's standard build procedures
# on Windows because the Ruby executable is
# built with VC++ while here we want to build
# with MingW.  So just roll our own...

require 'rake/clean'
require 'rbconfig'

RUBY_INCLUDE_DIR = Config::CONFIG["archdir"]
RUBY_BIN_DIR = Config::CONFIG["bindir"]
RUBY_LIB_DIR = Config::CONFIG["libdir"]
RUBY_SHARED_LIB = Config::CONFIG["LIBRUBY"]
RUBY_SHARED_DLL = RUBY_SHARED_LIB.gsub(/lib$/, 'dll')

CLEAN.include('*.o')
CLOBBER.include('ruby_prof.so')

task :default => "ruby_prof"

SRC = FileList['../ext/*.c']
OBJ = SRC.collect do |file_name|
   File.basename(file_name).ext('o')
end

SRC.each do |srcfile|
   objfile = File.basename(srcfile).ext('o')
   file objfile => srcfile do
     sh   "gcc -c -fPIC -O2 -Wall -o #{objfile} #{srcfile} 
-I#{RUBY_INCLUDE_DIR}"
   end
end

file "ruby_prof" => OBJ do
   sh "gcc -shared -o ruby_prof.so #{OBJ} 
#{RUBY_BIN_DIR}/#{RUBY_SHARED_DLL}"
end

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20080208/1fa0ae76/attachment.bin 


More information about the libxml-devel mailing list