Problems building gem with c-extension

Discussion in 'Ruby' started by Stefan Achatz, May 30, 2005.

  1. Hello,
    i want to build a gem with a c-extension.
    Some infos:
    Directory Stucture:
    mygem/mygem.gemspec
    mygem/lib/mydir/somefunctions.rb
    mygem/ext/extconf.rb
    mygem/ext/otherfunctions.c

    File mygem/ext/extconf.rb:
    require 'mkmf'
    create_makefile('mydir/otherfunctions')

    File mygem/mygem.gemspec:
    require 'rubygems'
    spec = Gem::Specification.new do |s|
    s.name = 'MyGem'
    s.version = '0.1.0'
    s.platform = Gem::platform::RUBY
    s.summary = 'Something that doesnt work'
    s.description = <<-EOF
    EOF
    s.require_path = 'lib'
    s.autorequire = 'mydir/somefunctions'
    s.has_rdoc = false
    s.files = Dir.glob("{ext,lib,tests}/**/{*.rb,*.c}")
    s.extensions = ['ext/extconf.rb']
    s.author = 'Stefan Achatz'
    s.email = ''
    end
    if $0 == __FILE__
    Gem::manage_gems
    Gem::Builder.new(spec).build
    end

    Now what does not work:
    when i go into the ext-dir and call manually
    ruby extconf.rb && make && make install
    the dir mydir gets created in the site-ruby-library-dir and the library gets
    copied there.

    When i build and try to install the gem with
    gem build mygem.gemspec
    gem install MyGem-0.1.0.gem

    the file otherfunctions.so gets copied to mygem/lib instead of
    mygem/lib/mydir

    a diff on the Makefiles resulting in the two ways show that the definitions
    of RUBYLIBDIR and RUBYARCHDIR are different.
    normal build results in $(sitelibdir)$(target_prefix) and
    $(sitearchdir)$(target_prefix).
    Whereas the gem-compile-process sets the dir fix to /usr/lib/.../MyGem/lib.

    What can i do to get the library in the right place for
    namespace-correctness?
    Thanks in advance
    Stefan Achatz
    Stefan Achatz, May 30, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. llothar
    Replies:
    0
    Views:
    264
    llothar
    Apr 3, 2008
  2. Jim Freeze
    Replies:
    6
    Views:
    151
    Chad Fowler
    May 13, 2005
  3. Austin 7873
    Replies:
    5
    Views:
    171
    Eric Hodel
    Jan 27, 2007
  4. Emmanuel Oga
    Replies:
    1
    Views:
    81
    Tom M
    Sep 7, 2007
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    142
    Iñaki Baz Castillo
    Feb 28, 2011
Loading...

Share This Page