3

i've been stuck on this problem for hours, without finding any solutions. I'm currently trying to compile lua 5.3.4 for Emscripten for use in my project. ive hit a roadblock thought, I need to compile it to a liblua.a file which ill later use when doing the emcc command line. but theres problems. heres the console output and what i do. ive gotten it to output .o files already. how do i put these in the .a (since i assume thats what its doing)

E:\code\liblua>make generic CC="emcc -s WASM=1"
cd src && make generic
make[1]: se ingresa al directorio `E:/code/liblua/src'
ar rcu liblua.a lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o 1lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
process_begin: CreateProcess(NULL, ar rcu liblua.a lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o, ...) failed.
make (e=2): El sistema no puede encontrar el archivo especificado. (system cannot find the specified file)
make[1]: *** [liblua.a] Error 2
make[1]: se sale del directorio `E:/code/liblua/src'
make: *** [generic] Error 2

what it says is that it cant find ar rcu, how do i use it on my system?

for reference, the system im trying to use can be found here https://github.com/vvanders/wasm_lua if its required

Free Renca
  • 83
  • 1
  • 7
  • hi, ive tried what you mentioned, but it does this E:\code\liblua>ar rvs liblua.a "ar" is not recognized as an internal or external command, executable program or batch file. i think its because my system doesnt have "ar". is there any way i can install it? or is it a linux only thing? – Free Renca Sep 24 '20 at 17:19
  • 1
    Yeah, I just tried your `rcu` options and it worked even if the archive wasn't there. What does your system say if you do `ar --version`? – Ted Lyngmo Sep 24 '20 at 17:20
  • Alright, i've tried ar --version, it's not outputting anything. Same error E:\code\liblua>ar --version "ar" is not recognized as an internal or external command, executable program or batch file. I'm on a windows system. Does this require linux? Or can I install it from somewhere? I do not have access to a linux machine at the moment, so I need a windows solution. – Free Renca Sep 24 '20 at 17:22
  • 1
    I'm not sure, but it looks like it tries to use *nix tools. You could install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2) + Ubuntu 20.04 on your windows machine. It's feels pretty close to working on a linux machine. `sudo apt install g++ binutils make libc-bin` should then give you some basic tools. – Ted Lyngmo Sep 24 '20 at 17:29
  • Alright. I've installed WSL2 and now I'm setting up the ubuntu 20.04 part, once it's done I run that, and then I should be able to use ar from cmd? or will I have to also do it from powershell? – Free Renca Sep 24 '20 at 17:35
  • 1
    You don't need to use powershell for anything if this works, only the Ubuntu [tag:bash] shell. The tools I listed may not be enough though. When you do `make ...` it may complain about other missing tools - but at least then it'll be simple. You only need to figure out in which package the tool exists and then install that package with `sudo apt install ` _`packagename`_ – Ted Lyngmo Sep 24 '20 at 17:40
  • 1
    Okay, after a while, I've gotten back to the ar rcu part, it seems to work now on the subsystem. theres another error though ar: liblua.a: Permission denied renca@LAPTOP-JDSC2N7P:~/lua-5.3.4/src$ ar rvs liblua.a ar: liblua.a: Permission denied – Free Renca Sep 24 '20 at 17:51
  • 1
    Odd... Check the permissions `ls -l liblua.a`. Is the file owned by `root` or you? It should be owned by you, so `sudo chown yourusername liblua.a` if it's not. Also check that it's writeable and make it so that if it isn't. – Ted Lyngmo Sep 24 '20 at 17:59
  • ls: cannot access 'liblua.a': No such file or directory The file doesn't exist. How do I create it? Do I have to escalate the permissions or something? – Free Renca Sep 24 '20 at 18:00
  • 1
    Check the directory permissions too. Nothing should be owned by `root` where you build this. I assume you build it as yourself and not `root`? – Ted Lyngmo Sep 24 '20 at 18:02
  • Okay, it indeed says everything is owned by root. How do I fix this? No idea how that happened. – Free Renca Sep 24 '20 at 18:05
  • 1
    You downloaded it as `root` I presume. In what directory are you when you try to `make`? – Ted Lyngmo Sep 24 '20 at 18:06
  • It's in /home/renca/lua5.3.4/. I'm in the folder when I try to do make. – Free Renca Sep 24 '20 at 18:08
  • 1
    Ok, `sudo chown -R renca:renca /home/renca/lua5.3.4` should make user `renca` and group `renca` the owner of every file in `lua5.3.4` and below. – Ted Lyngmo Sep 24 '20 at 18:10
  • 1
    Thanks. That made the command work. It outputted a liblua file. I'm gonna try using it now. – Free Renca Sep 24 '20 at 18:13
  • 1
    Great! Happy lua-hacking! :-) – Ted Lyngmo Sep 24 '20 at 18:14
  • Thanks. I guess this is resolved then. No idea how to mark it from here. – Free Renca Sep 24 '20 at 18:16
  • 1
    Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/222033/discussion-between-ted-lyngmo-and-free-renca). – Ted Lyngmo Sep 24 '20 at 18:23
  • 1
    Sorry for the lack of response, there. – Free Renca Oct 17 '20 at 23:20

1 Answers1

1

It looks like the requires Un*x tools so I suggest:

  • Install Windows Subsystem for Linux 2 (WSL2).
  • Install the Ubuntu 20.04 distribution in WSL2.
  • Start a shell by double clicking the Ubuntu 20.04 LTS icon.
  • From the shell, install the tools needed. A minimal set for this whould be:
    sudo apt install g++ binutils make libc-bin
    ... or for a more complete set of packages:
    sudo apt install build-essential
  • Unpack the lua distribution (as yourself, not the root user) somewhere in your home directory and try building.
Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108