Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config for windows 64 #500

Closed
albfan opened this issue Jul 17, 2015 · 12 comments
Closed

config for windows 64 #500

albfan opened this issue Jul 17, 2015 · 12 comments

Comments

@albfan
Copy link

albfan commented Jul 17, 2015

Trying to debug a windows 64 bits app, leads to:

$ error loading module 'socket.core' from file 'C:\projects\lua\ZeroBraneStudio/bin/clibs52/socket\core.dll':
        %1 is not a valid Win32 application.

Also I need to set zerobranestudio path with / or \\ dir separator \ is get as unicode escape sequence.

Details for issue on mridgers/clink#334.

Can ZeroBraneStudio debug 64bits apps. Can It be compiled for 64bits?

Any help is appreciated.

@pkulchenko
Copy link
Owner

@albfan, yes, it should all work with 64bit libraries, but you need to have luasocket compiled for your platform. The situation for the platforms is this:

  1. Linux: supports both 32bit and 64bit debugging using different libraries provided with the IDE
  2. OSX: supports both 32bit and 64bit debugging using one luasocket library compiled as a universal binary (so it can be loaded from both 32bit and 64bit Lua interpreter).
  3. Windows: supports both 32bit and 64bit debugging, but only 32bit library is included with the IDE. If you need to debug 64bit applications, you need to have 64bit luasocket either compiled statically with your app or available as a library. If you don't want to compile one yourself, I have the 64bit binary available.

I'll make sure this is covered in the documentation.

In terms of compiling ZBS for 64bits, it's probably possible, but I haven't tried this and don't see a pressing need to do this as you still should be able to debug 64bit apps from 32bit IDE.

@albfan
Copy link
Author

albfan commented Jul 18, 2015

I'm preparing a fork on gh-pages and master ide windows layout.

https://github.com/albfan/ZeroBraneStudio/commits/master

albfan@7306f9c

I can send PR if you find it useful.

Inspecting your 64 luasocket with http://www.dependencywalker.com/ shows it depends on lua51.dll, what about lua52 and lua53?

Looking for luasocket sources I have only found https://github.com/diegonehab/luasocket which says is 3.0-rc1

http://w3.impa.br/~diego/software/luasocket/ doesn't help much.

I have asked @diegonehab anyway lunarmodules/luasocket#125

@albfan
Copy link
Author

albfan commented Jul 18, 2015

With my fork I manage to start debug (now clink crashes but that's another history) If you are interested see mridgers/clink#334

@pkulchenko
Copy link
Owner

@albfan, it's not going to work this way. You can't simply drop lua51.dll as there is already supposed to be one included in your product (as statically compiled interpreter or as a DLL). In any case, if you add another one, you're likely to get interpreter conflict, which will lead to a crash.

(1) If you already have 64bit lua51.dll, you don't need anything else. (2) If you have lua51.dll with a different name, you need a proxy dll that will forward requests from lua51.dll to your dll. (3) if you have statically compiled interpreter, you'll need to have a different type of dll that will forward the requests to the statically compiled Lua functions.

Let me know which of the case match your situation and I can provide more details on how this can be done. There are instructions at the bottom of build/build-win32.sh, but they are for the reverse of the second case.

@albfan
Copy link
Author

albfan commented Jul 18, 2015

I didn't know internals of clink, hope @mridgers can help here.

https://github.com/albfan/clink/blob/master/lua/README#L2
https://github.com/albfan/clink/blob/master/premake4.lua#L166

seems it uses a lua52 compiled statically from sources. I guess it's third case.

@mridgers
Copy link

Correct. Clink uses Lua 5.2 which is statically linked into the DLL.

@pkulchenko
Copy link
Owner

@mridgers, @albfan, so you have two options:

(a) include luasocket into your static executable (in this case you can use ZBS to debug out of the box), or
(b) (1) compile the static interpreter that exposes Lua symbols, (2) compile 64bit lua socket against (real) lua52.dll, and (3) compile a proxy dll named lua52.dll, which you put into the same folder as clink executable.

For step 2 you can use the build scripts from ZeroBrane Studio; something like this should compile 64bit luasocket for Lua 5.2: (cd build; bash ./build-win32.sh lua 5.2 luasocket). This will build luasocket for lua5.2 and will put it into bin/clibs52 folder. If you run this with configured 64bit gcc, you'll get 64bit library.

For step 1 you can follow the directions here and for step 3 you can use the directions for Lua Proxy DLL 4, just replace Lua 5.1 with Lua 5.2.

I've done all this and the process works, but it involves several steps. I might be able to build luasocket for 64bit windows and build proxy DLLs for all the versions, just to save people some time, but it will probably be closer to the end of the month. The easiest way is to include luasocket into your statically compiled executable, but if it's not an option, we can make it work with the libraries as described above.

@albfan
Copy link
Author

albfan commented Jul 19, 2015

For me it sounds quite thrilling @pkulchenko! if you want to start a WIP branch maybe we can speed up this! a serie of tagged issues and a milestone could help others to collaborate.

@pkulchenko
Copy link
Owner

As the first step, I'd confirm with @mridgers that the executable exposes Lua symbols or that it can be made to expose them. According to the instructions I referenced, it may require MYCFLAGS=-DLUA_CORE -DLUA_BUILD_AS_DLL, but I'm not sure how to make it work with clink.

If that is done, I can build 64bit luasocket for Lua 5.2 and the appropriate proxy DLL to allow you, @albfan, to test it with clink (as long as the symbols are exported). It's will probably be couple of days before I get to it.

@albfan
Copy link
Author

albfan commented Jul 19, 2015

I'm proud to became a tester for this.

Don't hesitate to expand the test scope to support more scenarios related with 64bits, main objetive is to enhance ZeroBraneStudio.

@mridgers
Copy link

Clink can use Lua built as a DLL but it isn't quite as straight forward as just defining athe LUA_BUILD_AS_DLL because Clink injects its DLL into cmd.exe, and any dependencies such as a Lua DLL will also been to be injected.

Provided you have at least mridgers/clink@6d9e58e you can use this patch to build Lua as a DLL.

@pkulchenko
Copy link
Owner

@mridgers, thank you for the update; apologies I missed it earlier. @albfan, did you get it working?

hiili added a commit to hiili/WindowsTorch that referenced this issue Jul 27, 2017
TORCH_INSTALL_PATH=C:/torch
ZBS_INSTALL_PATH=X:/ZeroBraneStudio    # ZeroBrane Studio 1.60; MobDebug 0.648

# Needed for local debugging with ZeroBrane Studio
# Note that this is probably not the ideal solution
cp $TORCH_INSTALL_PATH/bin/libluajit.dll $TORCH_INSTALL_PATH/bin/lua51.dll

# See pkulchenko/ZeroBraneStudio#500 (comment)
wget https://download.zerobrane.com/luasocket-win64.zip
unzip luasocket-win64.zip -d $TORCH_INSTALL_PATH/bin

cp $ZBS_INSTALL_PATH/lualibs/mobdebug/mobdebug.lua $ZBS_INSTALL_PATH/lualibs/socket.lua -t $TORCH_INSTALL_PATH/lua
ghost pushed a commit to frango9000/PokeBotBad that referenced this issue Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants