3

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.

confusedandtired
  • 139
  • 1
  • 12
  • Can you add how borland builder 3 is being used in you project? Is it used to build your application? The lua interpreter? Was lpeg built with it? – greatwolf Aug 23 '13 at 21:41

1 Answers1

4

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.

lhf
  • 70,581
  • 9
  • 108
  • 149
  • Well there is no such thing as a lpeg.lua, so what is the standard re.lua trying to load? – confusedandtired Aug 23 '13 at 10:49
  • @confusedandtired, see my edited answer. Tell us the contents of the paths mentioned in the answer and where the DLL is. – lhf Aug 23 '13 at 10:51
  • 1
    Ah, ok. I didn't have the LUA_CPATH variable yet. I added it with the path for the dll. It looks like it's trying to load it now, but now I get an access violation in the lua5.1.dll when in luaD_call – confusedandtired Aug 23 '13 at 11:10