alien icon indicating copy to clipboard operation
alien copied to clipboard

Windows support

Open moteus opened this issue 8 years ago • 4 comments

Now problem with Windows that there no config.h files. And it require install mingw to be able use configure. I add this config.h file to my project

/* confdefs.h */
#define PACKAGE_NAME "alien"
#define PACKAGE_TARNAME "alien"
#define PACKAGE_VERSION "0.7.1"
#define PACKAGE_STRING "alien 0.7.1"
#define PACKAGE_BUGREPORT "http://mascarenhas.github.com/alien"
#define PACKAGE_URL ""
#define PACKAGE "alien"
#define VERSION "0.7.1"
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STDINT_H 1
#define LT_OBJDIR ".libs/"
#define STDC_HEADERS 1
#define HAVE_FFI_H 1

And I can compile alien with MSVC (with my fixes #49 , #50 , #51 ) and all tests pass. Also I add rockspec file to be able install it on Windows.

build = {
  type = "command",
  build_command = "./bootstrap && ./configure LUA=$(LUA) CPPFLAGS='-I$(LUA_INCDIR) -I$(FFI_INCDIR)' LDFLAGS=-L$(FFI_LIBDIR) --prefix=$(PREFIX) --libdir=$(LIBDIR) --datadir=$(LUADIR) && make clean && make",
  install_command = "make install",
  copy_directories = {},

  platforms = { windows = {
    type = "builtin",
    copy_directories = {},
    modules = {
      alien_c = {
        sources = {"src/alien.c"},
        defines = {"FFI_BUILDING", "WINDOWS"},
        libraries = {"ffi"},
        incdirs = {"$(FFI_INCDIR)"},
        libdirs = {"$(FFI_LIBDIR)"}
      },
      alien = 'src/alien.lua',
    }
  }}
}
>luarocks install https://raw.githubusercontent.com/moteus/alien/master/rockspecs/alien-scm-0.rockspec
Cloning into 'alien'...
remote: Counting objects: 2559, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 2559 (delta 17), reused 0 (delta 0), pack-reused 2527
Receiving objects: 100% (2559/2559), 2.58 MiB | 119.00 KiB/s, done.
Resolving deltas: 100% (1498/1498), done.
Checking connectivity... done.
cl /nologo /MD /O2 -c -Fosrc/alien.obj -Ic:/Lua/5.1/include/ src/alien.c -DFFI_BUILDING -DWINDOWS -Ic:/lua/external/include
alien.c
link -dll -def:alien_c.def -out:alien_c.dll c:/Lua/5.1/lib/lua51.lib src/alien.obj -libpath:c:/lua/external/lib ffi.lib
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

   Creating library alien_c.lib and object alien_c.exp
alien scm-0 is now installed in c:\Lua\5.1\systree (license: MIT/X11)

Also I add travis file to run tests on Travis CI service.

moteus avatar Aug 24 '16 10:08 moteus

I tried this and compiled the dll file but somehow not able to load it in windows. I am using Lua 5.3. When I require alien then I get the error saying:

error loading module 'alien_c' from file '.\alien_c.dll': The specified network name is no longer available

I tried changing the module name in the alien.c file and tried a couple of variations but no success. I thought it might be getting confused by the submodule syntax but when I changed it to alienc.dll with the function called luaopen_alienc, I was still having the same problem. Any hints or help would be useful.

aryajur avatar Apr 25 '18 01:04 aryajur

The problem was that libffi.dll was not in the path so it was not able to find it. Once I put that in there it worked.

aryajur avatar Apr 25 '18 17:04 aryajur

The problem was that libffi.dll was not in the path so it was not able to find it. Once I put that in there it worked.

Next time could use lucasg/Dependencies: A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues. to check dll libs dependences.

robertlzj avatar Jun 17 '22 16:06 robertlzj