当lua编译为c ++时,如何使用ZeroBrane Studio IDE调试器

时间:2017-11-14 06:15:56

标签: dll lua luasocket zerobrane

我已将Lua 5.3编译为32位c ++ DLL和exe。 DLL包含除lua.cpp和luac.cpp之外的所有lua代码。 exe编译lua.cpp并使用DLL运行lua解释器。从命令行自行运行时,这可以正常工作。我希望能够使用此DLL和exe从IDE运行。

如果我用自己的版本替换lua53.exe\ZeroBraneStudio\bin\clibs53\socket\core.dll,我可以运行脚本(单击两个绿色箭头)。但是,调试不起作用,给出以下错误:

  

程序入口点luaL_addlstring无法位于动态链接库lua53.dll中。

我可以看到这种情况正在发生,因为调试器正在使用luasocket。 lua53.dll依赖于omars-mbp:helloworld omarjandali$ ../start.sh Starting Gunicorn. [2017-11-13 22:10:43 -0800] [1238] [INFO] Starting gunicorn 19.6.0 [2017-11-13 22:10:43 -0800] [1238] [INFO] Listening at: http://0.0.0.0:8000 (1238) [2017-11-13 22:10:43 -0800] [1238] [INFO] Using worker: sync [2017-11-13 22:10:43 -0800] [1241] [INFO] Booting worker with pid: 1241 [2017-11-13 22:10:43 -0800] [1241] [ERROR] Exception in worker process Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker worker.init_process() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process self.load_wsgi() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi self.wsgi = self.app.wsgi() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app __import__(module) ModuleNotFoundError: No module named 'helloworld' [2017-11-13 22:10:43 -0800] [1241] [INFO] Worker exiting (pid: 1241) [2017-11-13 22:10:43 -0800] [1242] [INFO] Booting worker with pid: 1242 [2017-11-13 22:10:43 -0800] [1242] [ERROR] Exception in worker process Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker worker.init_process() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process self.load_wsgi() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi self.wsgi = self.app.wsgi() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app __import__(module) ModuleNotFoundError: No module named 'helloworld' [2017-11-13 22:10:43 -0800] [1242] [INFO] Worker exiting (pid: 1242) [2017-11-13 22:10:44 -0800] [1238] [INFO] Shutting down: Master [2017-11-13 22:10:44 -0800] [1238] [INFO] Reason: Worker failed to boot. ,并期望它包含编译为c的lua。

那么,对此的正确解决方案是什么 - 将luasocket编译成c ++也是如此?

(如果是的话,有没有人有这样的指示/指导?我一直无法找到任何相关内容。)

感谢。

2 个答案:

答案 0 :(得分:0)

我不确定DLL是如何编译的,但错误消息可能表明luaL_addlstring和其他函数未被导出。如果符号输出正确,您应该能够加载luasocket并使调试工作。请参阅this thread for the related discussion

此外,您不需要替换lua53库和可执行文件,因为您可以使用documentation中所述的path.lua53配置设置将IDE配置为使用您自己的副本。

答案 1 :(得分:0)

好的,我能够让它运转起来。解决方案是将luasocket编译为c ++。我不会在这里详细说明如何做到这一点,但有些人希望能帮助其他人解决同样的问题:

  • 从这里得到luasocket:https://github.com/diegonehab/luasocket
  • 将所有* .c文件重命名为* .cpp
  • 将Lua52.props重命名为Lua.props(我使用的是lua 5.3,但看起来它兼容?)
  • 在适当的文件夹中放置lua标头和lib
  • 在Visual Studio 2012中打开解决方案
  • 修复了项目文件的小问题,例如重命名文件。
  • 在luaopen_socket_core和luaopen_mime_core函数的声明中添加了'extern“C”'(lua能够加载库所必需的)。
  • 内置解决方案
  • 将新dll复制到clibs53 / socket和clibs53 / mime文件夹中。

我使用Dependency Walker来帮助解决这个问题。如果有人希望将来有更多细节,请发表评论。