# Ruby vtk bindings

**URL:** <https://www.ruby-forum.com/t/ruby-vtk-bindings/73902>\
**Category:** Ruby\
**Created:** [February 26, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/ruby-vtk-bindings/73902 "2006-02-26T20:06:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [February 26, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/ruby-vtk-bindings/73902/1 "2006-02-26T20:06:05Z")

</div>

I’m wanting to use ruby with VTK ([http://public.kitware.com/VTK/](http://public.kitware.com/VTK/)).  
Currently I’m getting errors compiling the ruby bindings  
([VTK-Ruby](http://www.gfd-dennou.org/arch/ruby/products/ruby-vtk/)):

g++ -fPIC -Wall -g -O2 -fPIC -I. -I/usr/lib/ruby/1.8/i486-linux  
-I/usr/lib/ruby/1.8/i486-linux -I. -DHAVE\_VTKCONFIGURE\_H  
-I/usr/include/vtk -c vtkTk.cxx  
In file included from vtkTk.cxx:1399:  
/usr/include/vtk/vtkTk.h:26:16: error: tk.h: No such file or directory  
vtkTk.cxx:343: warning: â??swig\_type\_info\*  
SWIG\_TypeDynamicCast(swig\_type\_info\*, void\*\*)â?? defined but not used  
vtkTk.cxx:366: warning: â??const char\* SWIG\_TypePrettyName(const  
swig\_type\_info\*)â?? defined but not used  
vtkTk.cxx:492: warning: â??char\* SWIG\_PackVoidPtr(char\*, void\*, const  
char\*, size\_t)â?? defined but not used  
vtkTk.cxx:503: warning: â??const char\* SWIG\_UnpackVoidPtr(const char\*,  
void\*\*, const char\*)â?? defined but not used  
vtkTk.cxx:516: warning: â??char\* SWIG\_PackDataName(char\*, void\*, size\_t,  
const char\*, size\_t)â?? defined but not used  
vtkTk.cxx:531: warning: â??const char\* SWIG\_UnpackDataName(const char\*,  
void\*, size\_t, const char\*)â?? defined but not used  
vtkTk.cxx:595: warning: â??swig\_type\_info\* SWIG\_TypeQuery(const char\*)â??  
defined but not used  
vtkTk.cxx:601: warning: â??void SWIG\_TypeClientData(swig\_type\_info\*,  
void\*)â?? defined but not used  
vtkTk.cxx:611: warning: â??void SWIG\_PropagateClientData(swig\_type\_info\*)â??  
defined but not used  
vtkTk.cxx:693: warning: â??VALUE SWIG\_Ruby\_NewPointerObj(void\*,  
swig\_type\_info\*, int)â?? defined but not used  
vtkTk.cxx:719: warning: â??VALUE SWIG\_Ruby\_NewClassInstance(VALUE,  
swig\_type\_info\*)â?? defined but not used  
vtkTk.cxx:798: warning: â??VALUE SWIG\_Ruby\_NewPackedObj(void\*, int,  
swig\_type\_info\*)â?? defined but not used  
vtkTk.cxx:810: warning: â??void SWIG\_Ruby\_ConvertPacked(VALUE, void\*, int,  
swig\_type\_info\*, int)â?? defined but not used  
vtkTk.cxx:855: warning: â??void SWIG\_AsVal(VALUE, int\*)â?? defined but not  
used  
make: \*\*\* [vtkTk.o] Error 1

The big mess of warnings is also somewhat worrisome, but I’d just like  
it to compile first. I’m running Ubuntu (Breezy) with all the latest  
updates. I installed vtk and tk through apt. I also made sure tk.h was  
on my system:  
$ find /usr/include -name tk.h  
/usr/include/tcl8.4/tk-private/generic/tk.h  
/usr/include/tcl8.4/tk.h

I don’t have much experience compiling my own libraries from scratch so  
I’m not quite sure what I’m doing wrong.

Also it seems the ruby bindings are somewhat old and not much is  
happening with them. Is there a gem out there or better documentation?

Thanks for the help!

-----Jay A.

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [February 27, 2006, 3:09am UTC](https://www.ruby-forum.com/t/ruby-vtk-bindings/73902/2 "2006-02-27T03:09:24Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I’m wanting to use ruby with VTK ([http://public.kitware.com/VTK/](http://public.kitware.com/VTK/)).

> Also it seems the ruby bindings are somewhat old and not much is  
> happening with them. Is there a gem out there or better documentation?
> 
> Thanks for the help!
> 
> -----Jay A.

The ruby-vtk works with VTK-4.4 but not VTK-5.0+  
Simple ruby programs work, but those that require interactive use

- similar to Python’s TkIntermodule were not working.  
They would require some ruby code to implement that module.

Even with that ruby-vtk, it is an alpha quality.  
There is no .gem package yet.  
The tar.gz was as easy as reading the instructions in that package.

To get a ruby interface for VTK-5.0 would require implementing a swig  
interface.  
That is quite a lot of work to get that implemented.

best regards,  
Gerald

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [February 27, 2006, 4:15am UTC](https://www.ruby-forum.com/t/ruby-vtk-bindings/73902/3 "2006-02-27T04:15:52Z")

</div>

Hmm… vtk-4.4 seems to be the default for ubuntu. Following the  
install instructions again for ruby-vtk I still get the compile error.  
Any ideas on why I might be having trouble compiling? Thanks!

-----Jay

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [February 27, 2006, 6:11am UTC](https://www.ruby-forum.com/t/ruby-vtk-bindings/73902/4 "2006-02-27T06:11:21Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hmm… vtk-4.4 seems to be the default for ubuntu. Following the  
> install instructions again for ruby-vtk I still get the compile error.  
> Any ideas on why I might be having trouble compiling? Thanks!
> 
> -----Jay

I used the tcl8.4.11 and tk8.4.11 src, which put all the headers in  
/usr/include/  
tcl.h tclDecls.h tclPlatDecls.h  
tk.h tkDecls.h tkPlatDecls.h

You need to put those headers where the Makefile finds them.  
Perhaps link the headers to /usr/include or use/local/include  
OR alter the Makefile generated to include the directories in  
which the headers are located.

regards,  
Gerald

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [February 27, 2006, 5:47am UTC](https://www.ruby-forum.com/t/ruby-vtk-bindings/73902/5 "2006-02-27T05:47:03Z")

</div>

From: removed\_email\_address@domain.invalid  
Subject: ruby vtk bindings  
Date: Mon, 27 Feb 2006 04:06:23 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Also it seems the ruby bindings are somewhat old and not much is  
> happening with them. Is there a gem out there or better documentation?

## Although I know this is NOT an answer which you want, Ruby/Tk can control VTK with its Tcl-wrapper. 🙂 For example, if you want to use a VTK-Tcl-script,

require ‘tk’

VTK\_TCLLIB = ‘/usr/local/lib/vtk/tcl’  
VTK\_EXAMPLE = ‘/usr/local/src/VTK/VTK/Examples/GUI/Tcl’  
VTK\_DATA = ‘/usr/local/src/VTK/VTKData’

Tk::AUTO\_PATH.lappend(VTK\_TCLLIB)

TkPackage.require(‘vtk’)  
TkPackage.require(‘vtkinteraction’)  
Tk.tk\_call(‘set’, ‘::VTK\_DATA\_ROOT’, VTK\_DATA)

Tk.load\_tclscript(File.join(VTK\_EXAMPLE, ‘ImagePlaneWidget.tcl’))

Tk.mainloop
