[Rubygems-developers] Having dynamic libraries installed in the bin directory without having them put in ruby's search path?

Eric Hodel drbrain at segment7.net
Tue Mar 20 01:38:59 EDT 2007

Stop top posting.

On Mar 19, 2007, at 19:21, Olivier Boudry wrote:
> On 3/19/07, Eric Hodel <drbrain at segment7.net> wrote:
>> On Mar 19, 2007, at 13:38, Olivier Boudry wrote:
>>> On 3/19/07, Eric Hodel <drbrain at segment7.net> wrote:
>>>> On Mar 19, 2007, at 07:58, Olivier Boudry wrote:
>>>>> I'm building the win32 gems for the SAP Rfc connector (a tool to
>>>>> perform remote function calls on a SAP R/3 system). I would  
>>>>> need to
>>>>> have dll files placed into the ruby\bin directory.
>>>> How do you run a shared library?
>>> I don't run them, but putting them as executables in the gemspec was
>>> the only way I found to get them installed in the ruby\bin  
>>> directory.
>>> Also I know this is not the purpose of the executables parameter.
>> So if you don't run them why are they in the bin dir?  Why aren't
>> they in the lib dir?
> Yes they should go in the lib dir if I was not using Windows. Windows
> searches for DLLs only in the system folder, in the applications
> directory (ruby.exe) and in the location specified in the PATH
> variable.
> If you have a look at files in the Ruby One Click Installer for
> Windows you'll notice that all DLL required by preinstalled modules
> (gdbm.dll, iconv.dll, libeay32.dll, zlib1.dll, ...) are placed in the
> bin directory. They are not executable but if you don't place them
> along the ruby.exe file the OS will not find them and you'll end-up
> with a load error.

Now I'm confused.  I was assuming you were dealing with shared  
libraries that would be loaded by require, not shared libraries that  
would be loaded by another shared library like ruby's shared  
libraries which live in C:\ruby\lib\ruby\1.8\i386-mswin32.

Is it correct that the shared libraries you are trying to put in the  
bin dir will not be loaded by require, but indirectly?

> I know my question is very Windows centric, because with other OS you
> would never put libraries in the same folder as executables files.
> Placing DLLs in the bin folder is probably not "state of the art" but
> it would allow shipping binary win32 gems that contains all the
> required dependencies and don't require additional application or
> libraries installation. So I was just wondering if it was available in
> gemspec.

If you have two shared libraries to load, one via require and the  
other via the required shared library give them different names (like  
zlib1.dll and zlib.so).  It'll be a much simpler solution.

Also, how does ruby get away with having zlib.so in a directory  
that's not in ENV['PATH']?  Can you use the same trick?

More information about the Rubygems-developers mailing list