lubyk / yaml

Yaml for Lubyk.
https://lubyk.github.io/lubyk/yaml.html
Other
19 stars 5 forks source link

Yaml does not build correctly with luarocks #4

Open code-fodder opened 8 years ago

code-fodder commented 8 years ago

I have tried two different ways to build this and both failed :(

  1. I downloaded yaml-1.1.2-1.src.rock from the Luarocks website and ran lua install yaml-1.1.2-1.src.rock
  2. downloaded the yaml-master.zip (top level) from the git repo and zipped it, cd into folder and then run luarocks make

Both produce the same error - here is a short snippet of the log:

D:\user\downloads\luarocks-2.3.0-win32\extras>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'

Note: that before installing this I succesfully installed its dependencies:

So I am not sure what is wrong...

siffiejoe commented 8 years ago

The reason is the __declspec(dllimport) decoration on Windows. See here. It can be fixed by defining YAML_DECLARE_STATIC in the rockspec (it's only necessary on Windows, so you could use per-platform-overrides, but since it isn't harmful on other platforms I wouldn't bother):

-- ...
      },
      incdirs   = {'src'},
      defines   = {'YAML_DECLARE_STATIC'},  -- <==
    },
-- ...