LuaSnip
LuaSnip copied to clipboard
jsregexp failed build on windows
Ouh, I have not seen that one before...
Could you try running make manually, and check if passing the full path to deps in -I works?
I think this worked:
gcc -IC:\Users\gdmr\AppData\Local\nvim-data\lazy\LuaSnip\deps\lua51_include\ -O2 -fPIC -c .\deps\jsr
egexp\jsregexp.c -o jsregexp.o
compiled without errors.
Oooh, okay took a look at the makefile, we do try to build the full path, but $(shell pwd) returned an empty path in your case.
IIRC, there have been windows-users without this issue in the past, could you try to figure out what is missing on your system?
I stumbled upon this as well.
In my case it seems that Make runs with CMD as shell, which doesn't have the pwd executable. I installed make from scoop instead of through something like mingw, cygwin or git bash, all of which runs in something closer to a POSIX shell.
I added this to the Makefile:
ifeq ($(OS),Windows_NT)
PWD := $(shell cd)
else
PWD := $(shell pwd)
endif
and then substituted $(shell pwd) with ${PWD} in the rest of the Makefile.
I then ran into some other errors (gcc is also from scoop but it seems to package mingw):
process_begin: CreateProcess(NULL, uname, ...) failed.
Makefile:37: pipe: Bad file descriptor
git submodule init
git submodule update
make "INCLUDE_DIR=-IC:\Users\oscar\AppData\Local\nvim-data\lazy\LuaSnip/deps/lua51_include/" LDLIBS="" -C deps/jsregexp
make[1]: Entering directory 'C:/Users/oscar/AppData/Local/nvim-data/lazy/LuaSnip/deps/jsregexp'
gcc -IC:\Users\oscar\AppData\Local\nvim-data\lazy\LuaSnip/deps/lua51_include/ -O2 -fPIC -c jsregexp.c -o jsregexp.o
gcc -IC:\Users\oscar\AppData\Local\nvim-data\lazy\LuaSnip/deps/lua51_include/ -O2 -fPIC -c cutils.c -o cutils.o
gcc -IC:\Users\oscar\AppData\Local\nvim-data\lazy\LuaSnip/deps/lua51_include/ -O2 -fPIC -c libregexp.c -o libregexp.o
gcc -IC:\Users\oscar\AppData\Local\nvim-data\lazy\LuaSnip/deps/lua51_include/ -O2 -fPIC -c libunicode.c -o libunicode.o
gcc -shared jsregexp.o cutils.o libregexp.o libunicode.o -o jsregexp.so
c:/users/oscar/scoop/apps/gcc/current/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: jsregexp.o:jsregexp.c:(.text+0x17): undefined reference to `luaL_checkudata'
c:/users/oscar/scoop/apps/gcc/current/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: jsregexp.o:jsregexp.c:(.text+0x7f): undefined reference to `lua_pushfstring'
c:/users/oscar/scoop/apps/gcc/current/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: jsregexp.o:jsregexp.c:(.text+0xb9): undefined reference to `luaL_checkudata'
[... errors truncated]
This is a bit above my level, but could it be due to similar problems that were noted on macos? i.e. LUA_LDLIBS=-undefined dynamic_lookup -all_load, which if I understand it correctly makes it so the darwin linker is more lax on undefined symbols? I tried looking for similar things to do on windows/mingw but couldn't find anything.
I added this to the Makefile: ...
Oh, yeah that's nice, unfortunately I don't think we can include it as-is, since it (should?) cause issues with more POSIX-like shells (I'll assume that $(OS) is not adjusted for those)
About the undefined symbols, no idea as well, I did some googling, but nothing looks promising :(
Another way of getting jsregexp is as a luarock, maybe that will work better?
You'd only have to remove the make jsregexp-part from your config, and install this rock (not the latest version!)
(you can check if it's available via :lua = require("luasnip.util.util").jsregexp), it should print a non-nil value.
I am having the same issues on Windows 11 and have tried absolutely everything. Tried installing every version of lua, luarocks, jsregexp etc.Tried installing directly, using choco, etc. No success. Did anyone get to the bottom of this and/or find any workarounds?
I got to the exact same point as @owallb above with all those undefined reference to... errors.
met the same problem on win11 too.
A way to work using MSYS2:
- install MSYS2
- open MSYS2 UCRT64 bash, install it's gcc and luajit toolchain. first do
pacman -Syu, thenpacman -S mingw-w64-ucrt-x86_64-luajit mingw-w64-ucrt-x86_64-make mingw-w64-ucrt-x86_64-gcc - change jsregexp and jsregexp005 makefile, move the link ldflags command to the end:
diff --git a/Makefile b/Makefile
index 2dd9165..6ed5959 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ CC = gcc
all: $(TARGET)
$(TARGET): $(OBJECTS)
- $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+ $(CC) $^ $(LDLIBS) -o $@ $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c $^ -o $@
- make jsregexp, running the follwing command.
mingw32-make CC=gcc CFLAGS="-I/ucrt64/include/luajit-2.1 -O2 -Wall -fPIC" LDFLAGS="-shared -lluajit-5.1" install_jsregexp
Another way is using luarocks, gcc (e.g. winlibs.com's distribution) and manually compiled luajit registered to luarocks, MSVC is not able to compile jsregexp. then copy the core.dll and its lua file manually. It's much more complicated.
Hello. I tried the option above, but it didn't help((. No solution yet?