mridgers / clink

Bash's powerful command line editing in cmd.exe
mridgers.github.io/clink
GNU General Public License v3.0
3.21k stars 283 forks source link

Extending CLink Lua Interpreter with external Modules #355

Open eMGabriel opened 9 years ago

eMGabriel commented 9 years ago
Hi! I'm using CLink on Win7 x64 architecture. I would like to include lua-lanes multithreading library into my command parser script. The lua-lanes module consists os two files: - lanes/core.dll - lanes.lua
I tried the following: I extended the path and cpath variables of Lua with the external Lua interpreter's lib path which has lua-lanes installed: ``` package.path = package.path..[[;c:\Program Files (x86)\Lua\5.1\lua\?.lua]] package.cpath = package.cpath..[[;c:\Program Files (x86)\Lua\5.1\clibs\?.dll]] local lanes = require "lanes" ``` The following error occured with CLink: ``` error loading module 'lanes.core' from file 'c:\Program Files (x86)\Lua\5.1\clibs\lanes\core.dll': %1 is not a valid Win32 application. ``` Although lua-lanes module is working with my installed Lua For Windows Lua 5.1 Interpreter 1. Is CLink Lua Interpreter x86 or x64 version? 2. For what architecture should I build lua-lanes on to work with the CLink embedded Lua interpreter?
mridgers commented 9 years ago

Clink downloads include builds for both x86 and x64. If you're running %windir%\system\cmd.exe on your Win7 x64 system then you'll use the x64 build of Clink. This means you have to have an x64 build of the lua-lanes DLL otherwise you won't be able to load the DLL.

x64 versions of Windows also include a full x86 subsystem too, located the SysWoW64 folder. So you do have to be mindful of how you launch cmd.exe. If you launch it from an x86 process then Windows will run the x86 build of cmd.exe (located in %windir%\SysWoW64\cmd.exe). Then you'll need an x86 build of core.dll.

One last important thing I've noticed. In your paths above you appear to be using Lua 5.1, but Clink is built using Lua 5.2.