How can I load third party dll?

Posted by Andy.Liu on Tue 07 Mar 2017 07:22 AM — 15 posts, 43,057 views.

#0
Dear Gammon,
I'm facing a problem when loading a third party dll name "luaiconv.dll", which provides encoding/decoding chars functions.

I can run it smoothly in command line in windows via Lua.exe.

When I load my Lua script,It can't find the module.

local iconv = require("luaiconv")
local cd = iconv.new("utf-8","gbk")
local words, err = cd:iconv(text)

There are 3 dlls: luaiconv.dll,iconv.dll,charset.dll .I tried to place them in these folders:1) same folder of the Lua script 2.root path of mush client
3) lua 5.1\clibs

But all failed.

Could you please help this ?

Thanks a lot.
USA Global Moderator #1
Quote:
...a third party dll...

Provide a link to these dlls, please, along with another link to the project page. We don't want to hunt all over the internet looking for something that may or may not be what you're trying to use.
Amended on Tue 07 Mar 2017 09:54 AM by Fiendish
#2
The homepage of luaiconv is http://ittner.github.io/lua-iconv/

The dlls I downloaded is from a chinese developer web site,but I don't think you can download it directly.

http://download.csdn.net/download/sniffer12345/6562595

I can send you email and attach them.

Please provide your email address if possible.

Thanks a lot.
USA Global Moderator #3
The project page says
Quote:
require("iconv")

But you are doing
Quote:

require("luaiconv")


If using iconv instead of luaiconv still doesn't work, please share the files with a service like https://nofile.io/
Amended on Tue 07 Mar 2017 06:53 PM by Fiendish
#4
Please download it by the following link:

https://share.weiyun.com/3c31f9f1734ad466cbee7e87cd782e14

Thanks.
USA Global Moderator #5
I just put those dlls in my mushclient folder and ran


local iconv = require("luaiconv")
local cd = iconv.new("utf-8","gbk")
local words, err = cd:iconv("hello")
print(words)

And it worked fine for me.

I assume your operating system is in Chinese and not English? Maybe that affects path searching.
Amended on Wed 08 Mar 2017 03:07 PM by Fiendish
#6
yes .It is Chinese Windows
I will try it in English
USA Global Moderator #7
If switching the OS to English works, please let us know. That might be fixable in MUSHclient.
Amended on Thu 09 Mar 2017 09:49 AM by Fiendish
#8
Sorry,I have no pure English Windows OS currently.
I tried utf8/gbk for lua script self.
And nothing changes.
It seems mushclient loaded or found dll successfully,but can't load
module 'luaiconv' successfully.

==============================
Run-time error
World: ashooter
Immediate execution
error loading module 'luaiconv' from file '.\luaiconv.dll':
ÕÒ²»µ½Ö¸¶¨µÄ³ÌÐò¡£

stack traceback:
[C]: ?
[C]: in function 'require'
[string "Script file"]:2: in main chunk
USA Global Moderator #9
Do you have MSVCR100.DLL? I notice luaiconv.dll requires it.
Amended on Thu 09 Mar 2017 01:02 PM by Fiendish
USA Global Moderator #10
For me,

require "tprint"; f = require("luaiconv"); tprint(f)

outputs

"iconv"=function: 0x026cb7e0
"VERSION"="luaiconv r5"
"ERROR_UNKNOWN"=4
"new"=function: 0x026cb800
"ERROR_INVALID"=2
"open"=function: 0x026cb820
"ERROR_INCOMPLETE"=3
"ERROR_NO_MEMORY"=1


I get the same with

require "tprint"; f = assert(package.loadlib("luaiconv.dll", "luaopen_luaiconv"))(); tprint(f)
#11
Yes,I have msvcr100.dll put in c:\windows\system32 folder.
#12
require("tprint");f = require("luaiconv");tprint(f)

GOT ERROR:

Run-time error
World: ashooter
Immediate execution
error loading module 'luaiconv' from file '.\luaiconv.dll':
The specified procedure could not be found.

stack traceback:
[C]: ?
[C]: in function 'require'
[string "Script file"]:4: in main chunk


require "tprint"; f = assert(package.loadlib("luaiconv.dll", "luaopen_luaiconv"))(); tprint(f)

GOT ERROR:

Run-time error
World: ashooter
Immediate execution
[string "Script file"]:6: The specified procedure could not be found.

stack traceback:
[C]: in function 'assert'
[string "Script file"]:6: in main chunk
#13
Hi,
A good news is that I can load this dll as you did.

I copied all the files in the Lua installed folder to the folder of MushClient and it works.

The bad news is that I don't know why it works now.

I think there are some relative files in the Lua installed folder that MuschClient missing.

The output is :
"ERROR_NO_MEMORY"=1
"ERROR_INCOMPLETE"=3
"iconv"=function: 05AC4C30
"VERSION"="luaiconv r5"
"ERROR_INVALID"=2
"ERROR_UNKNOWN"=4
"open"=function: 05AC1330
"new"=function: 05AC4C50
USA Global Moderator #14
I don't think I even have a Lua install.
Can you pin down which file or files fixed it?