lunarmodules / luafilesystem

LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.
https://lunarmodules.github.io/luafilesystem/
MIT License
907 stars 293 forks source link

Error when installing on windows via luarocks #169

Closed s4venth closed 1 year ago

s4venth commented 1 year ago

When installing via luarocks, I get this:

luafilesystem scm-1 depends on lua >= 5.1 (5.4-1 provided by VM)
C:\msys64\usr\bin\gcc.exe -O2 -c -o src/lfs.o -IC:\Users\strea\AppData\Local\Programs\Lua/include src/lfs.c
C:/msys64/usr/lib/gcc/x86_64-pc-msys/11.3.0/cc1.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

Error: Build error: Failed compiling object src/lfs.o
FractalU commented 1 year ago

Seems like you have an older version of msys2. Is your luarocks also installed on msys2 or is it luarocks on windows? Current msys2 has only mingw packages for luarocks. Also, can you install other packages such as lpeg or lsqlite3? I know that luarocks has issues with luafilesystem (see https://github.com/luarocks/luarocks/issues/1428), but I don't think it does apply to your case. I guess that the gcc compiler from msys2 is an unwanted effect from the os.execute command in lua which invokes the windows cmd. cmd searches for programs defined in the PATH environment variables. I guess you set the PATH environment variable to include C:\msys64\usr\bin path in order to run unix tools in msys2. Then, the cmd command from os.execute in luarocks accidentally stumbles across the gcc in msys2. Could you also provide the content of the PATH environment variables? More information would clarify things.

s4venth commented 1 year ago

The problem was indeed the msys2 version of gcc. Installing gcc through scoop, and changing my CC environment variable to that instead, fixed the problem.

Thanks for the help

FractalU commented 1 year ago

Glad I could help.

Ah, you used the CC environment variable to specify the C compiler. Then, my guess with the PATH environment variable was wrong.

For gcc in msys2, mostly the mingw packages are being used. It's odd that you installed gcc in C:\msys64\usr\bin. Maybe switching to mingw gcc in msys2 could also solve your problem.