[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Using DL on Windows

Stephan Kämper

3/23/2005 5:49:00 PM

Hi all,

I'm trying to tie together some Ruby code with a DLL (let's call it
'one.dll') which in turn uses another DLL. That other DLL is Xerces, but
that shouldn't matter much.

Now, if both of the two DLLs are located in the same directory as the
Ruby code things work fine.

I do something like:

dl_name = DL.dlopen( "one.dll" )
version = dl_name[ "version_of_XY" , "s" ]
puts "Version is : #{ version.call }"

Now, they're DLLs after all and I'd like to put both of them in another
directory, e.g. 'libs'. In that case I'd write

dl_name = DL.dlopen( "libs/one.dll" )
version = dl_name[ "version_of_XY" , "s" ]
puts "Version is : #{ version.call }"

and get an error:

dll_test.rb:47:in `initialize': unknown error (RuntimeError)
from dll_test.rb:47:in `dlopen'
from dll_test.rb:47


However, if I move the 'secondary' DLL (Xerces in this case) back into
the directory of the Ruby program everything is fine again.

So, my question is: How can I tell DL and/or Ruby where to look for
'secondary' DLLs? Apparently I have to take care about some kind of path
I'd guess. But which one?

Any help is really appreciated.

Happy rubying

Stephan
2 Answers

Dave Burt

3/23/2005 8:38:00 PM

0

"Stephan Kämper" <Stephan.Kaemper@Schleswig-Holstein.de> asked:
> Hi all,
>
> I'm trying to tie together some Ruby code with a DLL (let's call it
> 'one.dll') which in turn uses another DLL. That other DLL is Xerces, but
> that shouldn't matter much.
>
> Now, if both of the two DLLs are located in the same directory as the Ruby
> code things work fine.
> <snip>
> Now, they're DLLs after all and I'd like to put both of them in another
> directory, e.g. 'libs'. In that case I'd write
>
> dl_name = DL.dlopen( "libs/one.dll" )
> version = dl_name[ "version_of_XY" , "s" ]
> puts "Version is : #{ version.call }"
>
> and get an error:
>
> dll_test.rb:47:in `initialize': unknown error (RuntimeError)
> from dll_test.rb:47:in `dlopen'
> from dll_test.rb:47
> <snip>
> So, my question is: How can I tell DL and/or Ruby where to look for
> 'secondary' DLLs? Apparently I have to take care about some kind of path
> I'd guess. But which one?
>

DLLs need to be any one of:
* in the working directory,
* in the PATH,
* registered (regsvr32.exe one.dll) or
* referenced directly.

You should be able to do any of these first 3 quite easily. If you want them
in lib/, then I'd go for number 2:
ENV['PATH'] += ";.\\lib;" # UNTESTED

Cheers,
Dave


Stephan Kämper

3/23/2005 9:02:00 PM

0

Dave Burt wrote:
> "Stephan Kämper" <Stephan.Kaemper@Schleswig-Holstein.de> asked:
>
> DLLs need to be any one of:
> * in the working directory,
> * in the PATH,
> * registered (regsvr32.exe one.dll) or
> * referenced directly.
>
> You should be able to do any of these first 3 quite easily. If you want them
> in lib/, then I'd go for number 2:
> ENV['PATH'] += ";.\\lib;" # UNTESTED
>

Thanks a lot.

Happy rubying

Stephan