Need help packaging a library

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’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

Hi,

In [email protected]
“[ruby-gnome2-devel-en] need help packaging a library” on Sun, 3 Dec
2006 02:47:00 +0530,
“Martin DeMello” [email protected] 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
for Ruby/GLib:
CVS Info for project ruby-gnome2
for Ruby/Pango:
CVS Info for project ruby-gnome2

Thanks,

kou


Take Surveys. Earn Cash. Influence the Future of IT
Join 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

On 12/3/06, Kouhei S. [email protected] 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

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] need help packaging a library” on Sun, 3
Dec 2006 23:16:55 +0530,
“Martin DeMello” [email protected] 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’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

On 12/4/06, Kouhei S. [email protected] 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’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

On 12/5/06, Kouhei S. [email protected] wrote:

Hi,

2006/12/4, Martin DeMello [email protected]:

create_makefile_at_srcdir(“gtkwrapbox”, “src”)

create_makefile_at_srcdir(“gtkwrapbox”, File.expand_path(“src”))

Does this change work?

perfectly, thanks :slight_smile:

martin


Take Surveys. Earn Cash. Influence the Future of IT
Join 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

Hi,

2006/12/4, Martin DeMello [email protected]:

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’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