From: Hidetoshi NAGAI Date: 2011-04-05T07:16:10+09:00 Subject: Re: Tk and Tile with Tk8.5 From: Albert Schlef Subject: Re: Tk and Tile with Tk8.5 Date: Mon, 4 Apr 2011 21:57:34 +0900 Message-ID: <9fc745ebe20dd2e019f14c70fe9da7c4@ruby-forum.com> > > Just for curiosity, how do you toggle between the two? As I saw it the > > Tk version is compiled into the tcltklib.so. > > Right. I copy the 8.4 version into "tcltklib.so.84", and the 8.5 version > into "tcltklib.so.85", and my script simply copies the desired version > into "tcltklib.so". (To do this it uses the 'sudo' command because the > /usr/lib/ruby/1.8/i486-linux/ directory is writable for root only.) The following depend on an unofficial feature of ruby's dll loading. At present, it will work. But I don't recomment it. # I asked about the feature on ruby-dev ML. But I didn't discuss it. # Because I didn't have enough time for discussion and I thought # that there are not many people who requires such feature. In the following, denotes ruby's dll directory (.e.g /usr/lib/ruby/1.8/i486-linux). (1) Copy the 8.4 version to /tcltklib.8.4.so, and the 8.5 version to /tcltklib.8.5.so. Filenames must start by "tcltklib" + dot, and end by dot + "so". For example, "tcltklib.84.so" or "tcltklib.8.4.19.so" is OK, but "tcltklib_84.so" or "tcltklib.so.84" is NG. (2) Create loader script "tcltklib.rb" at ruby's library directory (.e.g /usr/lib/ruby/1.8). For example, ----- tcltklib.rb ----------------------------------------- ver = ENV['RUBYTK_VERSION'] if ver && !ver.empty? require "tcltklib.#{ver}.so" else require "tcltklib.so" end ----------------------------------------------------------- This exmaple selects the dll based on the environment variable. There are many way to decide the target dll. Please create your tcltklib.rb as you like. (3) If you use tcltklib.rb at step (2), $ RUBYTK_VERSION=8.4 ruby -r tk -e 'p Tk::TK_PATCHLEVEL' will use tcltklib.8.4.so (Tcl/Tk8.4 version), and $ RUBYTK_VERSION=8.5 ruby -r tk -e 'p Tk::TK_PATCHLEVEL' will use tcltklib.8.5.so (Tcl/Tk8.5 version) -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) Department of Artificial Intelligence, Kyushu Institute of Technology