title: Issues installing yaml for lua with luarocks during the c-compile
body: <p>I have lua, that I isntalled using luarocks.</p>
  
  <p><strong>Edit:</strong> on a windows system</p>
  
  <p>I successfully installed luasocket by downloading the luasocket-2.0.2-3.win32-x86.rock file from <a href="https://luarocks.org/modules/luarocks/luasocket/2.0.2-3" rel="nofollow noreferrer">v202-3 from here</a>. Its an older version, but it works.</p>
  
  <p>However now I need to install yaml so I can work with yaml files. Now I am forced to install using a *.src.rock file or a .rockspec file.</p>
  
  <p>I have tried:</p>
  
  <p><code>luarocks install yaml</code> which gives:</p>
  
  <pre><code>D:\user\workspace\_lua&gt;luarocks install yaml
  Warning: Failed searching manifest: Failed fetching manifest for https://luarocks.org - Failed downloading https://luarocks.org/manifest - C:\Users\user\AppData\Local/LuaRocks/Cache/https___luarocks.org/manifest
  Warning: Failed searching manifest: Failed fetching manifest for https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/ - Failed downloading https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/manifest - C:\Users\user\AppData\Local/LuaRocks/Cache/https___raw.githubusercontent.com_rocks-moonscript-org_moonrocks-mirror_master_/manifest
  Warning: Failed searching manifest: Failed fetching manifest for http://luafr.org/moonrocks/ - Failed downloading http://luafr.org/moonrocks/manifest - C:\Users\user\AppData\Local/LuaRocks/Cache/http___luafr.org_moonrocks_/manifest
  Warning: Failed searching manifest: Failed fetching manifest for http://luarocks.logiceditor.com/rocks - Failed downloading http://luarocks.logiceditor.com/rocks/manifest - C:\Users\user\AppData\Local/LuaRocks/Cache/http___luarocks.logiceditor.com_rocks/manifest
  
  Error: No results matching query were found.
  </code></pre>
  
  <p>So, then I downloaded <code>yaml-1.1.2-1.src.rock</code> and ran the command:
  <code>luarocks install yaml-1.1.2-1.src.rock</code></p>
  
  <p>This told me that I had dependencies yaml --> lub --> luafilesystem. so then I downloaded:</p>
  
  <ul>
  <li>luafilesystem-1.6.3-2.src.rock</li>
  <li>lub-1.1.0-1.src.rock</li>
  <li>yaml-1.1.2-1.src.rock</li>
  </ul>
  
  <p>And I installed them one after the other with the result:</p>
  
  <ul>
  <li><code>luarocks install luafilesystem-1.6.3-2.src.rock</code> - OK</li>
  <li><code>luarocks install lub-1.1.0-1.src.rock</code> - OK</li>
  <li><code>luarocks install yaml-1.1.2-1.src.rock</code> - FAILED, see errors below</li>
  </ul>
  
  <p>Error log:</p>
  
  <pre><code>D:\user\downloads\luarocks-2.3.0-win32\extras&gt;luarocks install yaml-1.1.2-1.src.rock
  Using yaml-1.1.2-1.src.rock... switching to 'build' mode
  mingw32-gcc -O2 -c -o src/api.o -ID:/user/install/lua/luarocks/include src/api.c -Isrc
  mingw32-gcc -O2 -c -o src/b64.o -ID:/user/install/lua/luarocks/include src/b64.c -Isrc
  mingw32-gcc -O2 -c -o src/dumper.o -ID:/user/install/lua/luarocks/include src/dumper.c -Isrc
  mingw32-gcc -O2 -c -o src/emitter.o -ID:/user/install/lua/luarocks/include src/emitter.c -Isrc
  mingw32-gcc -O2 -c -o src/loader.o -ID:/user/install/lua/luarocks/include src/loader.c -Isrc
  mingw32-gcc -O2 -c -o src/lyaml.o -ID:/user/install/lua/luarocks/include src/lyaml.c -Isrc
  mingw32-gcc -O2 -c -o src/parser.o -ID:/user/install/lua/luarocks/include src/parser.c -Isrc
  mingw32-gcc -O2 -c -o src/reader.o -ID:/user/install/lua/luarocks/include src/reader.c -Isrc
  mingw32-gcc -O2 -c -o src/scanner.o -ID:/user/install/lua/luarocks/include src/scanner.c -Isrc
  mingw32-gcc -O2 -c -o src/strtod.o -ID:/user/install/lua/luarocks/include src/strtod.c -Isrc
  In file included from src/strtod.c:23:0:
  src/strtod.c:24:17: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   extern  int     errno;
                   ^
  mingw32-gcc -O2 -c -o src/writer.o -ID:/user/install/lua/luarocks/include src/writer.c -Isrc
  mingw32-gcc -shared -o yaml/core.dll src/api.o src/b64.o src/dumper.o src/emitter.o src/loader.o src/lyaml.o src/parser.o src/reader.o src/scanner.o src/strtod.o src/writer.o D:/user/install/lua/luarocks/lua5.1.lib -lMSVCR80
  src/api.o:api.c:(.text+0x395): undefined reference to '_imp__yaml_realloc'
  src/api.o:api.c:(.text+0x412): undefined reference to '_imp__yaml_string_extend'
              :
      LOTS OF THESE
              :
  src/scanner.o:scanner.c:(.text.unlikely+0x29d0): undefined reference to '_imp__yaml_queue_extend'
  src/scanner.o:scanner.c:(.text.unlikely+0x29e8): undefined reference to '_imp__yaml_token_delete'
  collect2.exe: error: ld returned 1 exit status
  
  Error: Build error: Failed compiling module yaml/core.dll
  </code></pre>
  
  <p>Does anyone know why this build fails? - I got it directly from here: <code>https://luarocks.org/modules/gaspard/yaml/1.1.2-1</code> which is the most downloaded version... so I guess it should work?</p>
  
  <p>I mean, I can see what the error is... but I don't understand why there should be an error. How can I resolve this?... Any help appreciated :)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks to siffiejoe's comment, I was able to compile the yaml rock. Here is the output:</p>
  
  <pre><code>D:\user\downloads\luarocks-2.3.0-win32\extras&gt;luarocks install yaml-1.1.2-1.src.rock CC="gcc -DYAML_DECLARE_STATIC"
  Using yaml-1.1.2-1.src.rock... switching to 'build' mode
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/api.o -ID:/user/install/lua/luarocks/include src/api.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/b64.o -ID:/user/install/lua/luarocks/include src/b64.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/dumper.o -ID:/user/install/lua/luarocks/include src/dumper.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/emitter.o -ID:/user/install/lua/luarocks/include src/emitter.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/loader.o -ID:/user/install/lua/luarocks/include src/loader.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/lyaml.o -ID:/user/install/lua/luarocks/include src/lyaml.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/parser.o -ID:/user/install/lua/luarocks/include src/parser.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/reader.o -ID:/user/install/lua/luarocks/include src/reader.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/scanner.o -ID:/user/install/lua/luarocks/include src/scanner.c -Isrc
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/strtod.o -ID:/user/install/lua/luarocks/include src/strtod.c -Isrc
  In file included from src/strtod.c:23:0:
  src/strtod.c:24:17: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   extern  int     errno;
                   ^
  gcc -DYAML_DECLARE_STATIC -O2 -c -o src/writer.o -ID:/user/install/lua/luarocks/include src/writer.c -Isrc
  mingw32-gcc -shared -o yaml/core.dll src/api.o src/b64.o src/dumper.o src/emitter.o src/loader.o src/lyaml.o src/parser.o src/reader.o src/scanner.o src/strtod.o src/writer.o D:/user/install/lua/luarocks/lua5.1.lib -lMSVCR80
  Updating manifest for D:\user\install\lua\luarocks\systree/lib/luarocks/rocks
  yaml 1.1.2-1 is now built and installed in D:\user\install\lua\luarocks\systree (license: MIT)
  </code></pre>
  
  <p>So it says it is installed. However when I try to use the yaml packge it does not find it:</p>
  
  <pre><code>local yaml = require("yaml")
  local data = yaml.load("mytest.yaml")
  </code></pre>
  
  <p>The system reports that it can't find yaml.lua or yaml.dll. I then searched *.lua and *.dll in my luarocks folder I found:</p>
  
  <pre><code>D:\user\install\lua\luarocks\systree&gt;dir *.lua *.dll /b /s
  D:\user\install\lua\luarocks\systree\lib\lua\5.1\lfs.dll
  D:\user\install\lua\luarocks\systree\lib\lua\5.1\mime\core.dll
  D:\user\install\lua\luarocks\systree\lib\lua\5.1\socket\core.dll
  D:\user\install\lua\luarocks\systree\lib\lua\5.1\yaml\core.dll
  D:\user\install\lua\luarocks\systree\lib\luarocks\rocks\luafilesystem\1.6.3-2\tests\test.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\ltn12.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\mime.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\socket.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\lub\Autoload.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\lub\Dir.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\lub\init.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\lub\Param.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\lub\Template.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\socket\ftp.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\socket\http.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\socket\smtp.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\socket\tp.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\socket\url.lua
  D:\user\install\lua\luarocks\systree\share\lua\5.1\yaml\init.lua
  </code></pre>
  
  <p>For example, I managed to install luasocket with <code>luarocks install luasocket-2.0.2-3.win32-x86.rock</code> because there was a .rock file available. And so you can see there is a socket.lua. For yaml, lub and luafilesystem I can see various install locations, but there is no .lua or .dll files...
  I searched more for yaml specifically:</p>
  
  <pre><code>D:\user\install\lua\luarocks\systree&gt;dir *yaml* /b /s
  D:\user\install\lua\luarocks\systree\lib\lua\5.1\yaml
  D:\user\install\lua\luarocks\systree\lib\luarocks\rocks\yaml
  D:\user\install\lua\luarocks\systree\lib\luarocks\rocks\yaml\1.1.2-1\yaml-1.1.2-1.rockspec
  D:\user\install\lua\luarocks\systree\share\lua\5.1\yaml
  </code></pre>
  
  <p>ehh... so then I went and cloned the project from git (had to download the zip file because my stupid IT blocked my git clone ... (port 443).</p>
  
  <p>So finally got that sorted, then in the yaml-master folder I tried:</p>
  
  <p><code>luarocks make yaml-1.1.2-1.rockspec CC-"gcc -DYAML_DECLARE_STATIC"</code></p>
  
  <p>This had the same effect as before. So now I have tried both .src.rock and .rockspec types...</p>
  
  <p>I am stuck again :(</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>When I built from git, there was a file called yaml.lua in the top level. But all it contains is the text <code>yaml/init.lua</code> ... not sure what to do with that - tried copying it into the my <code>..install\lua\luarocks\systree\share\lua\5.1</code> dir, but when I run my test lua projam it gives an error.... what is going on, it can't be this hard to install :(</p>
  
  <p><strong>UPDATE 3</strong></p>
  
  <p>Following on from siffiejoe's great answer, I have more or less got this yaml installed. But I have a bug running it:</p>
  
  <p>Here is my lua script:</p>
  
  <pre><code>package.path = "D:\\user\\install\\lua\\luarocks\\systree\\share\\lua\\5.1\\?\\init.lua;" .. package.path
  print("package.path: " .. package.path)
  local yaml = require("yaml")
  local data = yaml.load("mytest.yaml")
  </code></pre>
  
  <p>I am manually adding the lua path for now while I am testing. When I run this I get the window:</p>
  
  <p><a href="https://i.stack.imgur.com/VwfbZ.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VwfbZ.gif" alt="enter image description here"></a></p>
  
  <p>And my log looks like:</p>
  
  <pre><code>D:\user\install\lua\luarocks\systree\share\lua\5.1\?\init.lua;D:\user\install\lua\luarocks\systree\share\lua\5.1\?.lua;D:\user\install\lua\luarocks\systree\share\lua\5.1\?\init.lua;./?.lua;./?/init.lua;./lua/?.lua;./lua/?/init.lua;D:\user\install\lua\zerobrane\lualibs/?/?.lua;D:\user\install\lua\zerobrane\lualibs/?.lua;D:\user\install\lua\zerobrane\lualibs/?/?/init.lua;D:\user\install\lua\zerobrane\lualibs/?/init.lua
  D:\user\install\lua\zerobrane\bin\lua.exe: error loading module 'lfs' from file 'D:\user\install\lua\luarocks\systree\lib\lua\5.1\lfs.dll':
      The specified procedure could not be found.
  
  
  stack traceback:
      [C]: at 0x66df0460
      [C]: in function 'require'
      ...\install\lua\luarocks\systree\share\lua\5.1\lub\init.lua:17: in main chunk
      [C]: in function 'require'
      ...install\lua\luarocks\systree\share\lua\5.1\yaml\init.lua:25: in main chunk
      [C]: in function 'require'
      D:\user\workspace\_lua\myluatest.lua:3: in main chunk
      [C]: at 0x00402a57
  Program completed in 56.64 seconds (pid: 15856).
  </code></pre>
  
  <p>So it appears to come back to this MSVCR80.dll ... this is not making sense to me, I assume this is do with microsoft... Some things I have read about it could be a corrupt MSVCR80.dll that needs replacing or somthing. But I am not yet sure about why this is occuring. Any thoughts?</p>