# Problem with mkmf-gnome2.rb in 0.17.0-rc1

**URL:** <https://www.ruby-forum.com/t/problem-with-mkmf-gnome2-rb-in-0-17-0-rc1/141092>\
**Category:** Ruby-Gnome 2\
**Created:** [June 21, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/problem-with-mkmf-gnome2-rb-in-0-17-0-rc1/141092 "2008-06-21T23:50:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [June 21, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/problem-with-mkmf-gnome2-rb-in-0-17-0-rc1/141092/1 "2008-06-21T23:50:44Z")

</div>

When trying to use my extconf.rb, with content:

-=-=----=-=----=-=----=-=----=-=—  
=begin  
extconf.rb for booh lib additions  
=end

PACKAGE\_NAME = “booh/libadds”

#- some adds to Gdk::Pixbuf  
require ‘mkmf-gnome2’  
PKGConfig.have\_package(‘gtk±2.0’) or exit 1  
have\_func(“gdk\_pixbuf\_set\_option”)  
have\_header(“gdk-pixbuf/gdk-pixbuf-io.h”)

#- direct exiv2 access for some EXIF stuff  
PKGConfig.have\_package(‘exiv2’) or exit 1

#- does it do something good, actually?  
setup\_win32(PACKAGE\_NAME)

create\_makefile\_at\_srcdir(PACKAGE\_NAME, ‘.’)  
-=-=----=-=----=-=----=-=----=-=—

and mkmf-gnome2.rb, the following output is produced:

-=-=—=-=—=-=—=-=—=-=—=-=–  
checking for GCC… yes  
checking for rb\_define\_alloc\_func() in ruby.h… yes  
checking for rb\_block\_proc() in ruby.h… yes  
checking for new allocation framework… yes  
checking for attribute assignment… yes  
checking for gtk±2.0… yes  
checking for gdk\_pixbuf\_set\_option()… yes  
checking for gdk-pixbuf/gdk-pixbuf-io.h… yes  
checking for exiv2… yes  
checking for G\_PLATFORM\_WIN32… no  
\*\*\* extconf.rb failed \*\*\*  
Could not create Makefile due to some reason, probably lack of  
necessary libraries and/or headers. Check the mkmf.log file for more  
details. You may need configuration options.

Provided configuration options:  
–with-opt-dir  
–without-opt-dir  
–with-opt-include  
–without-opt-include=${opt-dir}/include  
–with-opt-lib  
–without-opt-lib=${opt-dir}/lib  
–with-make-prog  
–without-make-prog  
–srcdir=.  
–curdir  
–ruby=/usr/bin/ruby  
–with-pkg-config  
–without-pkg-config  
/usr/lib/ruby/site\_ruby/1.8/mkmf-gnome2.rb:141:in  
`create_makefile_at_srcdir': undefined method `+’ for nil:NilClass  
(NoMethodError)  
from extconf.rb:19  
-=-=—=-=—=-=—=-=—=-=—=-=–

Instrumenting before the line 141, I can see that “srcdir” is “.” and  
“base\_dir” is “ext”, which effectively doesn’t give an apprently  
awaited result to “srcdir.rindex(base\_dir)” (my extconf.rb is in the  
subdirectory “ext” of my project). I don’t know exactly what the code  
is trying to do, so I cannot suggest a fix, sorry. Reverting commit  
2504 workarounds the problem though.

–  
Guillaume C. - [http://zarb.org/~gc/](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [June 22, 2008, 7:37am UTC](https://www.ruby-forum.com/t/problem-with-mkmf-gnome2-rb-in-0-17-0-rc1/141092/2 "2008-06-22T07:37:55Z")

</div>

Hi,

2008/6/22 Guillaume C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> is trying to do, so I cannot suggest a fix, sorry. Reverting commit  
> 2504 workarounds the problem though.

# What about the following patch?Index: src/lib/mkmf-gnome2.rb

— src/lib/mkmf-gnome2.rb (revision 3256)  
+++ src/lib/mkmf-gnome2.rb (working copy)  
@@ -138,7 +138,10 @@

def create\_makefile\_at\_srcdir(pkg\_name, srcdir, defs = nil)  
base\_dir = File.basename(Dir.pwd)

- builddir = srcdir[(srcdir.rindex(base\_dir) + base\_dir.size + 1)…-1]

- last\_common\_index = srcdir.rindex(base\_dir)
- if last\_common\_index
- builddir = srcdir[(last\_common\_index + base\_dir.size + 1)…-1]
- end  
builddir ||= “.”  
FileUtils.mkdir\_p(builddir)

And your extconf.rb should use File.dirname( **FILE** ) instead of “.”  
to support building your .so in other (not source) directory:

diff --git a/ext/extconf.rb b/ext/extconf.rb  
index 785e552…a591f1b 100644  
— a/ext/extconf.rb  
+++ b/ext/extconf.rb  
@@ -16,4 +16,4 @@ PKGConfig.have\_package(‘exiv2’) or exit 1  
#- does it do something good, actually?  
setup\_win32(PACKAGE\_NAME)

-create\_makefile\_at\_srcdir(PACKAGE\_NAME, ‘.’)  
+create\_makefile\_at\_srcdir(PACKAGE\_NAME, File.dirname( **FILE** ))

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [June 23, 2008, 12:06am UTC](https://www.ruby-forum.com/t/problem-with-mkmf-gnome2-rb-in-0-17-0-rc1/141092/3 "2008-06-23T00:06:49Z")

</div>

> - if last\_common\_index
> - builddir = srcdir[(last\_common\_index + base\_dir.size + 1)…-1]
> - end  
> builddir ||= “.”  
> FileUtils.mkdir\_p(builddir)

Works better, thanks.

> And your extconf.rb should use File.dirname( **FILE** ) instead of “.”  
> to support building your .so in other (not source) directory:

thanks!

–  
Guillaume C. - [Guillaume Cottenceau](http://zarb.org/~gc/)
