Using Ruby /DL to invoke function in custom dll

Joined
Jun 7, 2012
Messages
1
Reaction score
0
Hi,
I have used following code to invoke function from my custom dll
...................................
require 'dl'
require 'dl/import'
require 'dl/types'

module My
extend DL::Importable
dlload "unit.dll"
extern 'int BII_Initialize_Socket_Communications'
extern 'int BII_Open_TCPIP_Communications(char,unsigned short)'

end
My.BII_Initialize_Socket_Communications()
test = My.BII_Open_TCPIP_Communications("15.15.200.55",10001)

But its give me error like undefined method and
`symbol': can't find the symbol
 
Joined
Nov 23, 2023
Messages
59
Reaction score
3
Hi,
I have used following code to invoke function from my custom dll
...................................
require 'dl'
require 'dl/import'
require 'dl/types'

module My
extend DL::Importable
dlload "unit.dll"
extern 'int BII_Initialize_Socket_Communications'
extern 'int BII_Open_TCPIP_Communications(char,unsigned short)'

end
My.BII_Initialize_Socket_Communications()
test = My.BII_Open_TCPIP_Communications("15.15.200.55",10001)

But its give me error like undefined method and
`symbol': can't find the symbol
It looks like you're trying to use Ruby's DL library to interface with a custom DLL. The error message suggests that Ruby can't find the symbols you're trying to import from the DLL.
Here are a few things to check:
  1. Make sure the DLL file (unit.dll) is in the correct location and can be loaded by Ruby. You may need to provide the full path to the DLL if it's not in the same directory as your Ruby script.
  2. Verify that the function names (BII_Initialize_Socket_Communications and BII_Open_TCPIP_Communications) match exactly what's exported by the DLL. Case sensitivity matters, so ensure the function names are spelled correctly.
  3. Check the calling conventions of the functions in the DLL. Depending on how the DLL was compiled, you may need to specify the calling convention (e.g., cdecl, stdcall) in your extern declarations.
  4. Ensure that the function signatures in your extern declarations match the actual function signatures in the DLL. Pay attention to the number and types of arguments, as well as the return type.
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,271
Latest member
BuyAtenaLabsCBD

Latest Threads

Top