Zapk
Zapk

Reputation: 77

Compiling LuaSocket: Cannot open file: 'string.h'

The log:

C:\WINDOWS\system32>luarocks install luasocket
Installing https://luarocks.org/luasocket-3.0rc1-2.src.rock...
Using https://luarocks.org/luasocket-3.0rc1-2.src.rock... switching to 'build' mode
cl /nologo /MD /O2 -c -Fosrc/mime.obj -Ic:/lua/include/ src/mime.c -DLUA_COMPAT_APIINTCASTS -DLUASOCKET_DEBUG -DNDEBUG -DLUASOCKET_API=__declspec(dllexport) -DMIME_API=__declspec(dllexport)
mime.c
src/mime.c(5): fatal error C1083: Cannot open include file: 'string.h': No such file or directory

Error: Build error: Failed compiling object src/mime.obj

I'm very new to the whole LuaRocks thing, so I have no idea how to go about fixing this.

Upvotes: 1

Views: 2084

Answers (1)

James
James

Reputation: 1547

Here's a non-complete guide to get you started on installing lua modules from a fresh Windows 7.

1) We need LuaRocks in order to install Lua dependencies automatically (similar to cpan/cpanm in Perl or pip in Python). Download LuaRocks by grabbing the latest version with a "-win32.zip" suffix from here: http://keplerproject.github.io/luarocks/releases/

At the time of this writing, this is the following file: http://keplerproject.github.io/luarocks/releases/luarocks-2.3.0-win32.zip

2) Unzip it into a new directory and install it with install.bat /L. Without the "/L" flag, it will complain that it cannot find your existing Lua installation. With the flag, it will just install a new Lua binary (version 5.1). LuaRocks is now installed to C:\Program Files (x86)\LuaRocks. You may now delete the extracted "luarocks-2.3.0-win32" directory.

3) In order to compile and install modules, we will need a C++ compiler. Download and install the Visual C++ Build Tools 2015 from here: http://landinghub.visualstudio.com/visual-cpp-build-tools

(We want this so that we can avoiding installing the huge, multi-gigabyte Visual Studio 2015.)

4) Navigate to C:\Program Files (x86)\Microsoft Visual C++ Build Tools. Right click on "Visual C++ 2015 x86 Native Build Tools Command Prompt", and select "Run as administrator".

5) Run the following command: "C:\Program Files (x86)\LuaRocks\luarocks.bat" install luasocket.

Note that you may have to install additional stuff for certain modules. And sometimes, modules are simply unable to be compiled on Windows at all.

Upvotes: 2

Related Questions