1

I have this problem starting/debugging a project in ZeroBrane Studio. I have all source files.

Using a command in cmd.exe:

lib\lua52.exe OmapTest2.lua

starts the project, but I want to debug the project. When I execute the OmapTest2.lua in ZBS it gives me this .. error(?):

Program starting as '"C:\ZeroBraneStudio\bin\lua52.exe" -e "io.stdout:setvbuf('no')" "C:\ZeroBraneStudio\cfg\user.lua"'.
Program 'lua52.exe' started in 'C:\Radek\Tester' (pid: 9804).
C:\ZeroBraneStudio\bin\lua52.exe: C:\ZeroBraneStudio\bin\lua\iuplua.lua:6: attempt to index global 'iup' (a nil value)
stack traceback:
    C:\ZeroBraneStudio\bin\lua\iuplua.lua:6: in main chunk
    [C]: in function 'require'
    C:\ZeroBraneStudio\cfg\user.lua:1: in main chunk
    [C]: in ?
Program completed in 1.53 seconds (pid: 9804).

No idea what might be wrong. What I did is:

What should I do? Thanks in advance.

Balttazarr
  • 75
  • 2
  • 11
  • It seems that ZBS has a iuplua.lua file that is messing with the require on your code. The iuplua.lua file you downloaded is actually embedded in the the iuplua52.dll. So undo that, the IUP sources won't help you. – Antonio Scuri Aug 21 '20 at 13:40
  • If you take a look at the IUP documentation in IUP / Guide / Lua Binding, you will see that for require"iuplua" to work you need to use our LuaBinaries distribution or edit your LUA_CPATH – Antonio Scuri Aug 21 '20 at 13:42

1 Answers1

0

Copy pure C DLLs, like iup.dll to \ZeroBraneStudio\bin

Copy Lua modules DLLs, like iuplua52.dll to \ZeroBraneStudio\bin\clibs52

ZeroBrane Studio uses generic Lua DLLs that don't have the necessary suffix for IupLua in LUA_CPATH. So you need to manually add it. Edit the package.cpath at the beginning of your script:

package.cpath = package.cpath .. ";C:/ZeroBraneStudio/bin/clibs52/?52.dll"

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Antonio Scuri
  • 1,046
  • 6
  • 10
  • 1) I wasn't able to change package.cpath inside the Edit/Preferences/Settings because they are for the ZeroBrane environment only, not for the script environment. Each script has its own environment. – Antonio Scuri Aug 21 '20 at 17:04
  • 2) I had to hardcode the path C:/ZeroBraneStudio/bin/clibs52/ in the script because I couldn't find where it is exported to the script environment. – Antonio Scuri Aug 21 '20 at 17:07
  • 3) Would be nice if ZBS has support for the suffix embedded in its logic or if it start using the LuaBinaries distribution. – Antonio Scuri Aug 21 '20 at 17:12
  • I hardcoded the package.cpath in my script likeyou did, but where can I get Lua modules DLLs? Found iuplua52.dll in the project directory 'lib'. I also found many dlls in path C:\ZeroBraneStudio\bin like the the mentioned iuplua51.dll , lua52.dll and other.. Tried to run the script again with no success. – Balttazarr Aug 24 '20 at 07:20
  • The ZBS that I downloaded does not include IUP. I have to download IUP from the IUP web site. And there are 2 packages that you need to download, the IUP main package, and the IupLua 5.2 package. – Antonio Scuri Aug 25 '20 at 12:05
  • Could you please elaborate? What exactly to download, where to paste it in? I downloaded 'iup-3.30_Sources ', pasted 'iup' to a folder in my project 'lib' in ZeroBrane Studio in 'bin' in , 'src' and 'packages' and the main ZeroBrane Stuido catalog – Balttazarr Aug 28 '20 at 09:13
  • If you download sources, you will need a C/C++ compiler to build IUP from scratch. In the downloads you should select a pre-compiled binaries package. https://sourceforge.net/projects/iup/files/3.30/ For instance you can download the Tools Executables packages available here: https://sourceforge.net/projects/iup/files/3.30/Tools%20Executables/Lua52/ – Antonio Scuri Aug 29 '20 at 16:45
  • @AntonioScuri I followed your instructions and when I ran [sample.lua](https://www.tecgraf.puc-rio.br/iup/examples/Lua/sample.lua) I got "error loading module 'iuplua' from file 'C:/portable/ZeroBrane Studio/bin/clibs53/iuplua53.dll':" error. Any ideas on what to try next? So far I have added two files from `iup-3.30-Lua53_Win64_bin.zip`: `bin/iup.dll` and `bin/clibs53/iuplua53.dll`. – thdoan Nov 30 '21 at 18:58
  • That depends on which IUP package you downloaded. If it was a mingw generated DLLs (dllw6 for instance) they don't have extra dependencies. But if it was Visual C++ generated DLLs they depend on the VC run time library vcruntime##.dll or msvcr##.dll. – Antonio Scuri Dec 03 '21 at 12:52