Using DL on Windows

S

Stephan Kämper

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
 
D

Dave Burt

Stephan Kämper said:
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
 
S

Stephan Kämper

Dave said:
"Stephan Kämper" <[email protected]> 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,462
Latest member
ChanaLipsc

Latest Threads

Top