# Need help packaging a library

**URL:** <https://www.ruby-forum.com/t/need-help-packaging-a-library/78025>\
**Category:** Ruby-Gnome 2\
**Created:** [December 2, 2006, 10:18pm UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025 "2006-12-02T22:18:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 2, 2006, 10:18pm UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/1 "2006-12-02T22:18:28Z")

</div>

I’ve written wrappers for the gtk\_wrapbox set of widgets from gimp,  
which are currently compiling by means of a small shellscript that  
simply calls gcc on each file in turn and generates three .so files  
[pasted in below]. Now I need some help packaging them up properly  
with extconf.rb and some sort of uber-program that will pull them all  
into a single .so object. Anyone willing to help with this? I’m new to  
the whole ruby extension thing, and gtk looks like a daunting place to  
start.

martin

* * *

# make.sh

gcc -Wall -c gtkwrapbox.c -o gtkwrapbox.o `pkg-config --cflags gtk+-2.0`  
gcc -Wall -c gtkhwrapbox.c -o gtkhwrapbox.o `pkg-config --cflags gtk+-2.0`  
gcc -Wall -c gtkvwrapbox.c -o gtkvwrapbox.o `pkg-config --cflags gtk+-2.0`

INCLUDES=“-I. -I. -I/usr/lib/ruby/1.8/i686-linux -I…/./gtk  
-DHAVE\_RB\_DEFINE\_ALLOC\_FUNC -DHAVE\_RB\_BLOCK\_PROC  
-DHAVE\_OBJECT\_ALLOCATE -DHAVE\_NODE\_ATTRASGN -DRUBY\_GTK2\_TARGET="x11"  
-DHAVE\_GTK\_PLUG\_GET\_TYPE -DHAVE\_GTK\_SOCKET\_GET\_TYPE  
-DHAVE\_PANGO\_RENDER\_PART\_GET\_TYPE -DHAVE\_XREADBITMAPFILEDATA  
-DHAVE\_X11\_XLIB\_H -DHAVE\_XGETERRORTEXT -DRUBY\_GTK2\_COMPILATION  
-I/usr/lib/ruby/site\_ruby/1.8/i686-linux -I/usr/include/glib-2.0  
-I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0  
-I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo  
-I/usr/include/pango-1.0 -I/usr/include/glib-2.0  
-I/usr/lib/glib-2.0/include -I/usr/include/cairo  
-I/home/martin/code/ruby/gtk/ruby-gtk2-0.15.0/glib/src  
-I/home/martin/code/ruby/gtk/ruby-gtk2-0.15.0/pango/src”

DEFS=“-DHAVE\_RB\_DEFINE\_ALLOC\_FUNC -DHAVE\_RB\_BLOCK\_PROC  
-DHAVE\_OBJECT\_ALLOCATE -DHAVE\_NODE\_ATTRASGN -DRUBY\_GTK2\_TARGET="x11"  
-DHAVE\_GTK\_PLUG\_GET\_TYPE -DHAVE\_GTK\_SOCKET\_GET\_TYPE  
-DHAVE\_PANGO\_RENDER\_PART\_GET\_TYPE -DHAVE\_XREADBITMAPFILEDATA  
-DHAVE\_X11\_XLIB\_H -DHAVE\_XGETERRORTEXT -DRUBY\_GTK2\_COMPILATION”

CFLAGS=“-fPIC -O2 -march=i686 -Wall -pthread”

gcc $INCLUDES $CFLAGS -c rbgtkwrapbox.c  
gcc $INCLUDES $CFLAGS -c rbgtkvwrapbox.c  
gcc $INCLUDES $CFLAGS -c rbgtkhwrapbox.c

gcc $DEFS $CFLAGS -shared -o gtk\_wrap\_box.so -lc gtkwrapbox.o  
rbgtkwrapbox.o  
gcc $DEFS $CFLAGS -shared -o gtk\_hwrap\_box.so -lc rbgtkhwrapbox.o  
gtkhwrapbox.o  
gcc $DEFS $CFLAGS -shared -o gtk\_vwrap\_box.so -lc rbgtkvwrapbox.o  
gtkvwrapbox.o

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 3, 2006, 1:20pm UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/2 "2006-12-03T13:20:31Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] need help packaging a library” on Sun, 3 Dec  
2006 02:47:00 +0530,  
“Martin DeMello” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve written wrappers for the gtk\_wrapbox set of widgets from gimp,  
> which are currently compiling by means of a small shellscript that  
> simply calls gcc on each file in turn and generates three .so files  
> [pasted in below]. Now I need some help packaging them up properly  
> with extconf.rb and some sort of uber-program that will pull them all  
> into a single .so object. Anyone willing to help with this? I’m new to  
> the whole ruby extension thing, and gtk looks like a daunting place to  
> start.

extconf.rb in Ruby-GNOME2 project helps you:  
for Ruby/GTK+:  
[CVS Info for project ruby-gnome2](http://ruby-gnome2.cvs.sourceforge.net/ruby-gnome2/ruby-gnome2/gtk/extconf.rb?revision=HEAD&view=markup)  
for Ruby/GLib:  
[CVS Info for project ruby-gnome2](http://ruby-gnome2.cvs.sourceforge.net/ruby-gnome2/ruby-gnome2/glib/extconf.rb?revision=HEAD&view=markup)  
for Ruby/Pango:  
[CVS Info for project ruby-gnome2](http://ruby-gnome2.cvs.sourceforge.net/ruby-gnome2/ruby-gnome2/pango/extconf.rb?revision=HEAD&view=markup)  
…

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 3, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/3 "2006-12-03T18:47:06Z")

</div>

On 12/3/06, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> extconf.rb in Ruby-GNOME2 project helps you:  
> for Ruby/GTK+:

## Thanks, I was able to get something worked up using the gtk and gtktrayicon extconfs as examples. One last problem - this works:

require ‘mkmf’  
require ‘mkmf-gnome2’

PKGConfig.have\_package(‘gtk±2.0’) or exit 1  
begin  
require ‘gtk2’  
rescue =\> e  
$stderr.puts “Ruby/GTK couldn’t be initialized (‘#{e}’)”  
exit 1  
end

## create\_makefile(“gtkwrapbox”, “src”)

but spits the .o files out into the toplevel directory. Replacing the  
last line with

create\_makefile\_at\_srcdir(“gtkwrapbox”, “src”)  
create\_top\_makefile([“src”])

as in the gtk example fails in the make stage with

$ make  
make[1]: Entering directory `/home/martin/code/ruby/gtk/wrapbox/src' make[1]: Nothing to be done for `all’.  
make[1]: Leaving directory `/home/martin/code/ruby/gtk/wrapbox/src’

I’ve attached the generated src/Makefile - any idea what I’m doing  
wrong?

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 4, 2006, 10:42am UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/4 "2006-12-04T10:42:47Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] need help packaging a library” on Sun, 3  
Dec 2006 23:16:55 +0530,  
“Martin DeMello” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## create\_makefile(“gtkwrapbox”, “src”)
> 
> but spits the .o files out into the toplevel directory. Replacing the  
> last line with
> 
> create\_makefile\_at\_srcdir(“gtkwrapbox”, “src”)  
> create\_top\_makefile([“src”])
> 
> as in the gtk example fails in the make stage with

Do you place your \*.c files into src/ directory? And do you  
place your extconf.rb into top directory of your project?

your-project - extconf.rb  
|  
+ src - a.c  
- b.c  
- …

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 4, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/5 "2006-12-04T20:06:33Z")

</div>

On 12/4/06, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Do you place your \*.c files into src/ directory? And do you  
> place your extconf.rb into top directory of your project?
> 
> your-project - extconf.rb  
> |  
> + src - a.c  
> - b.c  
> - …

yes - here’s my entire structure:

$ tree  
.  
|-- Makefile  
|-- extconf.rb  
|-- mkmf.log  
|-- sample  
| `-- test.rb `– src  
|-- global.h  
|-- gtkbox.h  
|-- gtkhwrapbox.c  
|-- gtkhwrapbox.h  
|-- gtkvwrapbox.c  
|-- gtkvwrapbox.h  
|-- gtkwrapbox.c  
|-- gtkwrapbox.h  
|-- init.c  
|-- rbgtk.h  
|-- rbgtkbox.c  
|-- rbgtkhwrabox.c  
|-- rbgtkhwrapbox.c  
|-- rbgtkvwrapbox.c  
`-- rbgtkwrapbox.c

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 5, 2006, 5:32am UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/6 "2006-12-05T05:32:09Z")

</div>

On 12/5/06, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> 2006/12/4, Martin DeMello [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > create\_makefile\_at\_srcdir(“gtkwrapbox”, “src”)
> 
> create\_makefile\_at\_srcdir(“gtkwrapbox”, File.expand\_path(“src”))
> 
> Does this change work?

perfectly, thanks 🙂

martin

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 5, 2006, 1:57am UTC](https://www.ruby-forum.com/t/need-help-packaging-a-library/78025/7 "2006-12-05T01:57:46Z")

</div>

Hi,

2006/12/4, Martin DeMello [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> create\_makefile\_at\_srcdir(“gtkwrapbox”, “src”)

create\_makefile\_at\_srcdir(“gtkwrapbox”, File.expand\_path(“src”))

Does this change work?

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
