how to use / include lpeg luapeg re module

1.5k views Asked by At

ATM I'm trying to execute lua files from my application, this works with the basic lua. I'm using a borland compiler (builder 3, just don't ask >.<)

Now I'm trying to use lpeg via the re module. I've added the lpeg directory to the LUA_PATH environment variable. This directory includes re. lua, lpeg.dll from LuaForWindows and the *.c files.

Now when I try to start my script I get the error error loading module 'lpeg' from file 'lpeg.dll': lpeg.dll:1: syntax error near char(144)

The same script runs perfectly in the IExecutor from LuaForWindows.

I guess I've setup my lua environment completely wrong. Where do I put the dll? Do I have to build it myself with my compiler? (tried, but failed)

Thanks in advance.

1

There are 1 answers

3
lhf On

The error message hints that Lua tried to load a DLL as a Lua script. There are separate paths for DLL and for Lua libraries, don't mix the two.

In other words, if Lua finds a DLL using the path in LUA_PATH or package.path, it will try to load it as a Lua script. Put the DLL where it is found using LUA_CPATH or package.cpath.