Can't use rust-lua53 in Win7x64


#1

Hi all!
I’m trying to use Lua in my Rust project, but I can’t. I’ve tried MSYS64, MinGW and Cygwin with different errors.
Last time I’ve tried MSYS64 and the liblua.a was built, the glue.exe was built, but glue.rs didn’t.

And one more thing - I’ve compiled something myself and saw that there was a !feature syntax that wasn’t supported by anything but nightlies, it is sad too.

Please give some advice, I’ve tried for three days already :frowning:


#2

Please provide more information. The actual errors you get for every combination you’ve tried. Note that there are also MSVC-compatible Rust builds, maybe you want those?

It’s not sad, it’s Rust’s promise that anything the stable compiler accepts, no matter what flags or settings you set, the code will still compile to the same final program (same logical program, not same binary). The feature flags in the nightly are things that are still prone to sudden changes and breakage. Therefor they are removed from the stable compiler.


#3

Okay, If I use MSYS, and install tar which is not included from the installation I get this:

$ cargo build --verbose
   Compiling bitflags v0.1.1
     Running `rustc C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\bitflags-0.1.1\\src\\lib.rs --crate-name bitflags --crate-type lib -g -C metadata=dd68b8369bcd8ff0 -C extra-filename=-dd68b8369bcd8ff0 --out-dir C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --emit=dep-info,link -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --cap-lints allow`
   Compiling lua v0.0.8
     Running `rustc C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\lua-0.0.8\\build.rs --crate-name build_script_build --crate-type bin -g --out-dir C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\build\\lua-cdb404e9f559b4c8 --emit=dep-info,link -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --cap-lints allow`
     Running `C:\Users\REVERSE\RustProjects\lua_test\target\debug\build\lua-cdb404e9f559b4c8\build-script-build`
failed to run custom build command for `lua v0.0.8`
Process didn't exit successfully: `C:\Users\REVERSE\RustProjects\lua_test\target\debug\build\lua-cdb404e9f559b4c8\build-script-build` (exit code: 101)
--- stdout
lua-5.3.0/
lua-5.3.0/src/
lua-5.3.0/src/liolib.c
lua-5.3.0/src/lctype.h
lua-5.3.0/src/ltm.h
lua-5.3.0/src/ldump.c
lua-5.3.0/src/lobject.h
lua-5.3.0/src/lopcodes.h
lua-5.3.0/src/luac.c
lua-5.3.0/src/lbitlib.c
lua-5.3.0/src/llimits.h
lua-5.3.0/src/luaconf.h
lua-5.3.0/src/lgc.h
lua-5.3.0/src/lauxlib.c
lua-5.3.0/src/lstate.h
lua-5.3.0/src/llex.c
lua-5.3.0/src/ldblib.c
lua-5.3.0/src/lcode.h
lua-5.3.0/src/lstate.c
lua-5.3.0/src/lua.c
lua-5.3.0/src/lzio.c
lua-5.3.0/src/lcode.c
lua-5.3.0/src/llex.h
lua-5.3.0/src/lparser.c
lua-5.3.0/src/linit.c
lua-5.3.0/src/ldebug.h
lua-5.3.0/src/lcorolib.c
lua-5.3.0/src/lbaselib.c
lua-5.3.0/src/ldebug.c
lua-5.3.0/src/lutf8lib.c
lua-5.3.0/src/lapi.c
lua-5.3.0/src/lua.h
lua-5.3.0/src/lauxlib.h
lua-5.3.0/src/lobject.c
lua-5.3.0/src/lstrlib.c
lua-5.3.0/src/ltm.c
lua-5.3.0/src/ltablib.c
lua-5.3.0/src/lualib.h
lua-5.3.0/src/lfunc.h
lua-5.3.0/src/ldo.c
lua-5.3.0/src/lfunc.c
lua-5.3.0/src/lctype.c
lua-5.3.0/src/lvm.c
lua-5.3.0/src/loadlib.c
lua-5.3.0/src/ltable.h
lua-5.3.0/src/lstring.h
lua-5.3.0/src/ltable.c
lua-5.3.0/src/lua.hpp
lua-5.3.0/src/lopcodes.c
lua-5.3.0/src/lapi.h
lua-5.3.0/src/lparser.h
lua-5.3.0/src/Makefile
lua-5.3.0/src/lundump.c
lua-5.3.0/src/lmem.h
lua-5.3.0/src/lundump.h
lua-5.3.0/src/lprefix.h
lua-5.3.0/src/lstring.c
lua-5.3.0/src/lmathlib.c
lua-5.3.0/src/lvm.h
lua-5.3.0/src/lgc.c
lua-5.3.0/src/ldo.h
lua-5.3.0/src/lzio.h
lua-5.3.0/src/loslib.c
lua-5.3.0/src/lmem.c
lua-5.3.0/README
lua-5.3.0/doc/
lua-5.3.0/doc/luac.1
lua-5.3.0/doc/osi-certified-72x60.png
lua-5.3.0/doc/manual.css
lua-5.3.0/doc/readme.html
lua-5.3.0/doc/logo.gif
lua-5.3.0/doc/contents.html
lua-5.3.0/doc/manual.html
lua-5.3.0/doc/lua.1
lua-5.3.0/doc/lua.css
lua-5.3.0/Makefile

--- stderr
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = c:/progra~1/wget/etc/wgetrc
--2015-10-20 15:22:25--  http://www.lua.org/ftp/lua-5.3.0.tar.gz
Resolving www.lua.org... 148.251.24.173
Connecting to www.lua.org|148.251.24.173|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 278045 (272K) [application/gzip]
Saving to: `lua-5.3.0.tar.gz'

     0K .......... .......... .......... .......... .......... 18%  358K 1s
    50K .......... .......... .......... .......... .......... 36%  701K 0s
   100K .......... .......... .......... .......... .......... 55%  623K 0s
   150K .......... .......... .......... .......... .......... 73% 6,14M 0s
   200K .......... .......... .......... .......... .......... 92%  569K 0s
   250K .......... .......... .                               100% 9,29M=0,4s

2015-10-20 15:22:26 (697 KB/s) - `lua-5.3.0.tar.gz' saved [278045/278045]

thread '<main>' panicked at 'Error: File not found. (os error 2)', C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\build.rs:96

#4

if you follow the error message

thread '<main>' panicked at 'Error: File not found. (os error 2)', C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\build.rs:96

You can see that there’s an error in the build-script of the lua crate. If you open the file you can see what command is run. I’m assuming that you are missing gcc, but I can’t find the correct build.rs in the github repos, so you need to check yourself in your local file.


#5

Yes, you are right. In the MSYS installation there was no tar, no gcc and no make commands.
(The current build file is here: https://github.com/jcmoyer/rust-lua53/blob/master/build.rs)
I’ve installed them and I have another error:

$ cargo build --verbose
       Fresh bitflags v0.1.1
   Compiling lua v0.0.8
     Running `C:\Users\REVERSE\RustProjects\lua_test\target\debug\build\lua-cdb404e9f559b4c8\build-script-build`
     Running `rustc C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\lua-0.0.8\\src\\lib.rs --crate-name lua --crate-type lib -g -C metadata=cdb404e9f559b4c8 -C extra-filename=-cdb404e9f559b4c8 --out-dir C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --emit=dep-info,link -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --extern bitflags=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps\\libbitflags-dd68b8369bcd8ff0.rlib --cap-lints allow -L native=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\build\\lua-cdb404e9f559b4c8\\out\\lua-5.3.0\\src -l static=lua`
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\ffi/mod.rs:296:5: 296:9 error: file not found for module `glue`
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\ffi/mod.rs:296 mod glue;
                                                                                                        ^~~~
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\ffi/mod.rs:296:5: 296:9 help: name the file either glue.rs or glue/mod.rs inside the directory "C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\lua-0.0.8\\src\\ffi"
Could not compile `lua`.

Caused by:
  Process didn't exit successfully: `rustc C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\lib.rs --crate-name lua --crate-type lib -g -C metadata=cdb404e9f559b4c8 -C extra-filename=-cdb404e9f559b4c8 --out-dir C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps --emit=dep-info,link -L dependency=C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps -L dependency=C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps --extern bitflags=C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\libbitflags-dd68b8369bcd8ff0.rlib --cap-lints allow -L native=C:\Users\REVERSE\RustProjects\lua_test\target\debug\build\lua-cdb404e9f559b4c8\out\lua-5.3.0\src -l static=lua` (exit code: 101)

As I understood the glue.rs can’t be created. I’ve managed to compile glue.exe myself by issuing gcc command, but I didn’t understand properly which folder it needs to be in while generating glue.rs.

$ gcc -I "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\build\\lua-cdb404e9f559b4c8\\out\\lua-5.3.0\\src" "C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\lua-0.0.8\\src\\glue\\glue.c" -o glue
$ C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\lua-0.0.8\\src\\glue.exe glue.rs

Again, I’ve run glue.exe and have a glue.rs. I put it to ffi folder, tried to build the project, but the error is new and more scary:

$ cargo build --verbose
       Fresh bitflags v0.1.1
   Compiling lua v0.0.8
     Running `rustc C:\\msys64\\home\\REVERSE\\.cargo\\registry\\src\\github.com-0a35038f75765ae4\\lua-0.0.8\\src\\lib.rs --crate-name lua --crate-type lib -g -C metadata=cdb404e9f559b4c8 -C extra-filename=-cdb404e9f559b4c8 --out-dir C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --emit=dep-info,link -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --extern bitflags=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps\\libbitflags-dd68b8369bcd8ff0.rlib --cap-lints allow -L native=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\build\\lua-cdb404e9f559b4c8\\out\\lua-5.3.0\\src -l static=lua`
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96:3: 96:50 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277]
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96   fn from_lua(state: &mut State) -> Option<Self>;
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96:3: 96:50 help: run `rustc --explain E0277` to see a detailed explanation
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96:3: 96:50 note: `Self` does not have a constant size known at compile-time
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96:3: 96:50 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96   fn from_lua(state: &mut State) -> Option<Self>;
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\msys64\home\REVERSE\.cargo\registry\src\github.com-0a35038f75765ae4\lua-0.0.8\src\wrapper\convert.rs:96:3: 96:50 note: required by `core::option::Option`
   Compiling lua_test v0.1.0 (file:///C:/Users/REVERSE/RustProjects/lua_test)
     Running `rustc src\\main.rs --crate-name lua_test --crate-type bin -g --out-dir C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug --emit=dep-info,link -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug -L dependency=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps --extern lua=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps\\liblua-cdb404e9f559b4c8.rlib -L native=C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\build\\lua-cdb404e9f559b4c8\\out\\lua-5.3.0\\src`
error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-libgcc" "-m64" "-L" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\lua_test.0.o" "-o" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\lua_test.exe" "-Wl,--gc-sections" "-L" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug" "-L" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps" "-L" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\build\\lua-cdb404e9f559b4c8\\out\\lua-5.3.0\\src" "-L" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\.rust\\bin\\x86_64-pc-windows-gnu" "-L" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\bin\\x86_64-pc-windows-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps\\liblua-cdb404e9f559b4c8.rlib" "C:\\Users\\REVERSE\\RustProjects\\lua_test\\target\\debug\\deps\\libbitflags-dd68b8369bcd8ff0.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcollections-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_unicode-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\librand-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc_jemalloc-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-10cbabc2.rlib" "C:\\Program Files\\Rust nightly 1.5\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-10cbabc2.rlib" "-l" "ws2_32" "-l" "userenv" "-l" "advapi32" "-l" "compiler-rt"
note: C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib(lauxlib.o):lauxlib.c:(.text+0x242): undefined reference to `__errno'
C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib(lauxlib.o):lauxlib.c:(.text+0x316): undefined reference to `__getreent'
C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib(lauxlib.o):lauxlib.c:(.text+0x32e): undefined reference to `__getreent'
C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib(lauxlib.o):lauxlib.c:(.text+0x911): undefined reference to `__errno'
C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib(lauxlib.o):lauxlib.c:(.text+0x1150): undefined reference to `__getreent'
ld: C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib(lauxlib.o): bad reloc address 0x0 in section `.pdata'

error: aborting due to previous error
Could not compile `lua_test`.

Caused by:
  Process didn't exit successfully: `rustc src\main.rs --crate-name lua_test --crate-type bin -g --out-dir C:\Users\REVERSE\RustProjects\lua_test\target\debug --emit=dep-info,link -L dependency=C:\Users\REVERSE\RustProjects\lua_test\target\debug -L dependency=C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps --extern lua=C:\Users\REVERSE\RustProjects\lua_test\target\debug\deps\liblua-cdb404e9f559b4c8.rlib -L native=C:\Users\REVERSE\RustProjects\lua_test\target\debug\build\lua-cdb404e9f559b4c8\out\lua-5.3.0\src` (exit code: 101)

#6

msys has a mingw64_shell.bat. First of all I suggest to use that.

Are you running the MSVC compatible rustc or the gcc compatible one?

Do the compiler’s architectures match up (32bit vs 64bit)?


#7

Before the Lua I’ve used gcc (I think) and compiled from cmd.exe by “cargo build”. The Rust is x64 and Win is x64.

Edit: Tried in “MinGW-w64 Win64 Shell” - the same errors :frowning:


#8

try googling the error. A quick search found http://www.gamedev.net/topic/405112-why-is-lua-messing-up-my-linkage-to-the-crt-libraries/ which says there’s a mingw version of lua


#9

I did it!!!
I’ve run “MinGW-w64 Win32 Shell”, then installed:

pacman -S tar wget mingw32/mingw-w64-i686-gcc

and then created new project from example, and it did build like a charm.
Next step is to try to build the project to x64 binary…