Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build silently fails on Windows #60

Open
leonardus opened this issue Jan 31, 2024 · 1 comment
Open

Build silently fails on Windows #60

leonardus opened this issue Jan 31, 2024 · 1 comment

Comments

@leonardus
Copy link

leonardus commented Jan 31, 2024

>luarocks install lyaml YAML_DIR="C:\PROGRAM FILES\LIBYAML" YAML_INCDIR="C:\PROGRAM FILES\LIBYAML\INCLUDE" YAML_LIBDIR="C:\PROGRAM FILES\LIBYAML"
Installing https://luarocks.org/lyaml-6.2.8-1.src.rock

lyaml 6.2.8-1 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM)
C:\Program Files\lua/lua.exe build-aux/luke package="lyaml" version="6.2.8" PREFIX="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1" CFLAGS="/nologo /MD /O2" LIBFLAG="/nologo /dll" LIB_EXTENSION="dll" OBJ_EXTENSION="obj" LUA="C:\Program Files\lua/lua.exe" LUA_DIR="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1/lua" LUA_INCDIR="C:\Program Files\lua/include" YAML_DIR="C:\PROGRAM FILES\LIBYAML" YAML_INCDIR="C:\PROGRAM FILES\LIBYAML\INCLUDE" YAML_LIBDIR="C:\PROGRAM FILES\LIBYAML"
C:\Program Files\lua/lua.exe build-aux/luke install --quiet INST_LIBDIR="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1/lib" INST_LUADIR="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1/lua"
lyaml 6.2.8-1 is now installed in C:\Users\Leonardus\AppData\Roaming/luarocks (license: MIT/X11)

However, lyaml is not installed to %APPDATA%\luarocks\share\lua\5.4, and attempting to load it fails:

>lua script.lua
lua: script.lua:3: module 'lyaml' not found:
        no field package.preload['lyaml']
        no file 'C:\Program Files\luarocks\lua\lyaml.lua'
        no file 'C:\Program Files\luarocks\lua\lyaml\init.lua'
        no file 'C:\Program Files\luarocks\lyaml.lua'
        no file 'C:\Program Files\luarocks\lyaml\init.lua'
        no file 'C:\Program Files\luarocks\..\share\lua\5.4\lyaml.lua'
        no file 'C:\Program Files\luarocks\..\share\lua\5.4\lyaml\init.lua'
        no file '.\lyaml.lua'
        no file '.\lyaml\init.lua'
        no file 'C:\Users\Leonardus\AppData\Roaming/luarocks/share/lua/5.4/lyaml.lua'
        no file 'C:\Users\Leonardus\AppData\Roaming/luarocks/share/lua/5.4/lyaml/init.lua'
        no file ''
        no file 'C:\Program Files\luarocks\lyaml.dll'
        no file 'C:\Program Files\luarocks\..\lib\lua\5.4\lyaml.dll'
        no file 'C:\Program Files\luarocks\loadall.dll'
        no file '.\lyaml.dll'
        no file 'C:\Users\Leonardus\AppData\Roaming/luarocks/lib/lua/5.4/lyaml.dll'
        no file 'C:\Program Files (x86)\wxLua\bin\lyaml.dll'
        no file ''
stack traceback:
        [C]: in function 'require'
        script.lua:3: in main chunk
        [C]: in ?

I attempted to write a rockspec, but there's a linking problem that I've been trying to resolve for about four hours now and I haven't made any progress.

local _MODREV, _SPECREV = 'git', '-1'

package = 'lyaml'
version = _MODREV .. _SPECREV

description = {
   summary  = 'libYAML binding for Lua',
   detailed = 'Read and write YAML format files with Lua.',
   homepage = 'http://github.com/gvvaughan/lyaml',
   license  = 'MIT/X11',
}

source = {
   url = 'http://github.com/gvvaughan/lyaml/archive/v' .. _MODREV .. '.zip',
   dir = 'lyaml-' .. _MODREV,
}

dependencies = {
   'lua >= 5.1, < 5.5',
}

external_dependencies = {
   YAML = {
     header = 'yaml.h',
     --library = 'yaml',
   },
}

build = {
   type = 'builtin',
   modules = {
      yaml = {
         sources = {
            'ext/yaml/emitter.c',
            'ext/yaml/parser.c',
            'ext/yaml/scanner.c',
            'ext/yaml/yaml.c'
         },
         incdirs = { '$(YAML_INCDIR)', '$(LUA_INCDIR)' },
         libdirs = { '$(YAML_LIBDIR)', '$(YAML_BINDIR)' },
         libraries = { 'yaml' },
         defines = {
            'PACKAGE=lyaml',
            'VERSION=' .. _MODREV,
            'NDEBUG=1',
            '_FORTIFY_SOURCE=2'
         }
      }
   },
   install = {
      lua = {
         ['lyaml'] = 'lib/lyaml/init.lua',
         ['lyaml.explicit'] = 'lib/lyaml/explicit.lua',
         ['lyaml.functional'] = 'lib/lyaml/functional.lua',
         ['lyaml.implicit'] = 'lib/lyaml/implicit.lua'
      },
   },
   copy_directories = {'doc'}
}

if _MODREV == 'git' then
   build.copy_directories = nil

   source = {
      url = 'git://github.com/gvvaughan/lyaml.git',
   }
end

Below is the linking error, if anyone is interested and/or more experienced than me with building on Windows:

>luarocks make YAML_DIR="c:\program files\libyaml"

lyaml git-1 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM)
cl /nologo /MD /O2 -c -Foext/yaml/emitter.obj -IC:\Program Files\lua/include ext/yaml/emitter.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
emitter.c
cl /nologo /MD /O2 -c -Foext/yaml/parser.obj -IC:\Program Files\lua/include ext/yaml/parser.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
parser.c
cl /nologo /MD /O2 -c -Foext/yaml/scanner.obj -IC:\Program Files\lua/include ext/yaml/scanner.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
scanner.c
cl /nologo /MD /O2 -c -Foext/yaml/yaml.obj -IC:\Program Files\lua/include ext/yaml/yaml.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
yaml.c
link -dll -def:yaml.def -out:yaml.dll C:\Program Files\lua/lib/lua5.4.lib ext/yaml/emitter.obj ext/yaml/parser.obj ext/yaml/scanner.obj ext/yaml/yaml.obj -libpath:c:\program files\libyaml -libpath:c:\program files\libyaml/bin yaml.lib
Microsoft (R) Incremental Linker Version 14.38.33133.0
Copyright (C) Microsoft Corporation.  All rights reserved.

lua5.4.lib(lstate.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
Microsoft (R) Incremental Linker Version 14.38.33133.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   Creating library yaml.lib and object yaml.exp
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_stream_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_stream_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_document_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_document_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_alias_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_scalar_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_sequence_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_sequence_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_mapping_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_mapping_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_delete
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_set_output
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_set_width
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_set_unicode
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_emit
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_event_delete
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_initialize
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_initialize
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_delete
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_delete
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_set_input_string
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_set_input_string
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_parse
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_token_delete
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_scan
yaml.dll : fatal error LNK1120: 23 unresolved externals

Error: Build error: Failed compiling module yaml.dll

I built libyaml as a static library; installing from luarocks also silently fails the same way when libyaml is built as a .dll.

@leonardus
Copy link
Author

leonardus commented Jan 31, 2024

I've also tried building libyaml as a shared library, which allows to successfully compile, link, and install lyaml with the modified Rockspec, just with this error when trying to load ylaml (specifically when include('yaml') is called).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant