[CANCELLED][Windows] require DLL

Hi, thanks for this fantastic project.
I am trying to load a DLL that I have created. The DLL conforms to the LUA specifications. When I use “require”, I it tries to look for a LUA file instead of a DLL. If I use “package.loadlib()”, it seems to load the lib without errors but I get an error calling a function.

local path = "C:\\MyModule.dll"
local MyModule = assert(loadlib(path, "luaopen_MyModule"))
MyModule()  -- actually open the library
--local MyModule = require("MyModule") -- => loading MyModule.dll => executing luaopen_MyModule()

local w, h = MyModule.getDimensions()    
print("getDimensions: " .. w .. " " .. h)

local result = MyModule.getMessage(1,"Hello", 3.5, true)
print(result)
2 Likes

Interesting. I don’t think anyone has tried this before with Defold. What if you pprint() MyModule. What is printed? A user data pointer?

pprint(MyModule) returns

DEBUG:SCRIPT: function: 0x01900c615be0

I am going to use FFI instead, seems much easier to interface with standard dll’s. Also easier for me to write the dll’d

local ffi = package.preload.ffi()
ffi.cdef[[
const char* Pa_GetVersionText(void);
]]
local test = ffi.load("C:\\libportaudio64bit")
print(ffi.string(test.Pa_GetVersionText()))

returns DEBUG:SCRIPT: PortAudio V19.7.0-devel, revision 147dd722548358763a8b649b3e4b41dfffbcfbb6

1 Like

Cool. May I ask what you are creating?

I have designed an audio engine that allows you to process audio coming or going to any windows app. For example, you could add a reverb effect to your microphone before it reaches viber or you could boost the audio for all apps that playback sound. It also has its own low latency ASIO driver that gets converted to WDMKS with only 3ms of latency. It can do many other audio related things. I want to see if I can implement the GUI with Defold.

2 Likes

Cool! Sounds like a fun project!

Depending on the complexity of the UI you can either use the built in capabilities or use something like the ImGUI extension or Druid.

1 Like

Thanks, I’ll check them out. I am very new to Lua and Defold so I know I have long difficult road ahead of me.

1 Like