From: Luis Lavena Date: 2008-12-03T11:19:23+09:00 Subject: Re: crate 0.1.1 Released On Dec 2, 4:12 pm, Joel VanderWerf wrote: > Jeremy Hinegardner wrote: > > On Tue, Dec 02, 2008 at 11:04:32AM +0900, Luis Lavena wrote: > .. > >> I'll need to check it out how it works with gems that depends on > >> extensions, since dlopen / LoadLibrary needs a real file and cannot > >> map a memory address to load the symbols (just thinking out loud here, > >> maybe you already figured this out). > > > You might call it cheating, what I do is clear out $LOAD_PATH after > > initializing the interpreter and before handing off control to the > > wrapped up ruby application.  The require order is then, the ruby > > original require followed by the amalgalite overridden require.   > > > That way, if the require is a loaded module (which is now statically > > compiled in) the ruby internal rb_require() will return success, and if > > it is a .rb file LoadError will be raised and then amalgalite will take > > care of loading the appropriate file from the sqlite database. > > So, still wondering about Luis's question... how do you load extensions? > I got my answer looking at Jeremy presentation at RubyConf. Basically you "integrate" the gem C extension into ruby itself, so there is no need to carry the .so files around. The only problem with that approach is you need to install all the required dependencies to build those extensions, and have some gems developers play nice in their extconf.rb files too. Yet still, the ruby interpreter is quite capable of loading the .so files form the file system if they existed. Regards, -- Luis Lavena