Giter Club home page Giter Club logo

Comments (25)

Tieske avatar Tieske commented on July 24, 2024

Unfortunately the commit didn't fix it.

Luarocks output ends here;

mingw32-gcc -shared -o ssl.dll src/x509.o src/context.o src/ssl.o src/luasocket/buffer.o src/luasocket/io.o src/luasocke
t/timeout.o src/luasocket/wsocket.o -Lc:/external/lib -Lc:/external/bin -llibeay32 -lssleay32 -lws2_32 C:/Program Files
(x86)/Lua/5.1/bin/lua51.dll -lm
src/x509.o:x509.c:(.text+0xb71): undefined reference to `inet_ntop'
collect2.exe: error: ld returned 1 exit status

Error: Build error: Failed compiling module ssl.dll

Press any key to close this window...

searching on this inet_ntop thing tells me that Windows doesn't have it

from luasec.

brunoos avatar brunoos commented on July 24, 2024

It works on VC 12.

from luasec.

Tieske avatar Tieske commented on July 24, 2024

Not on MinGW (and apparently not on any older VC versions). Here's the code; https://github.com/diegonehab/luasocket/blob/76ed24fe8ae8c728de0d7d065918a5cd74fe7303/src/inet.c#L515-537

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Digging around, found this:

warmcat/libwebsockets#100 (comment)

from luasec.

brunoos avatar brunoos commented on July 24, 2024

Could you try the last version.

Note:

/*
 * For WinXP (SP3), set the following preprocessor macros:
 *     LUASEC_INET_NTOP
 *     WINVER=0x0501
 *     _WIN32_WINNT=0x0501
 *     NTDDI_VERSION=0x05010300
 *
 * For IPv6 addresses, you need to add IPv6 Protocol to your interface.
 */

from luasec.

Tieske avatar Tieske commented on July 24, 2024

Tried it today, but failed again.

When building the rockspec:

luarocks make

mingw32-gcc -O2 -c -o src/x509.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/x509.c -DWIN32 -DNDEBUG -D_WINDOWS
 -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/include -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/context.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/context.c -DWIN32 -DNDEBUG -D_W
INDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/include -Isrc/ -Isrc/luaso
cket
mingw32-gcc -O2 -c -o src/ssl.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/ssl.c -DWIN32 -DNDEBUG -D_WINDOWS -
D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/include -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/buffer.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/buffer.c -DW
IN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/include
-Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/io.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/io.c -DWIN32 -DN
DEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/include -Isrc/ -
Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/timeout.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/timeout.c -
DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/includ
e -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/wsocket.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/wsocket.c -
DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -Ic:/external/includ
e -Isrc/ -Isrc/luasocket
mingw32-gcc -shared -o ssl.dll src/x509.o src/context.o src/ssl.o src/luasocket/buffer.o src/luasocket/io.o src/luasocke
t/timeout.o src/luasocket/wsocket.o -Lc:/external/lib -Lc:/external/bin -llibeay32 -lssleay32 -lws2_32 C:/Program Files
(x86)/Lua/5.1/bin/lua51.dll -lm
src/x509.o:x509.c:(.text+0xb71): undefined reference to `inet_ntop'
collect2.exe: error: ld returned 1 exit status

Error: Build error: Failed compiling module ssl.dll

Press any key to close this window...

After modifying the rockspec to define "LUASEC_INET_NTOP" it still fails;

luarocks make

mingw32-gcc -O2 -c -o src/x509.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/x509.c -DWIN32 -DNDEBUG -D_WINDOWS
 -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -Ic:/external/include -Isrc
/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/context.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/context.c -DWIN32 -DNDEBUG -D_W
INDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -Ic:/external/include
 -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/ssl.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/ssl.c -DWIN32 -DNDEBUG -D_WINDOWS -
D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -Ic:/external/include -Isrc/
-Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/buffer.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/buffer.c -DW
IN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -Ic
:/external/include -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/io.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/io.c -DWIN32 -DN
DEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -Ic:/extern
al/include -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/timeout.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/timeout.c -
DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -
Ic:/external/include -Isrc/ -Isrc/luasocket
mingw32-gcc -O2 -c -o src/luasocket/wsocket.o -IC:/Program Files (x86)/Lua/5.1/include/lua/5.1 src/luasocket/wsocket.c -
DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLSEC_EXPORTS -DBUFFER_DEBUG -DLSEC_API=__declspec(dllexport) -DLUASEC_INET_NTOP -
Ic:/external/include -Isrc/ -Isrc/luasocket
mingw32-gcc -shared -o ssl.dll src/x509.o src/context.o src/ssl.o src/luasocket/buffer.o src/luasocket/io.o src/luasocke
t/timeout.o src/luasocket/wsocket.o -Lc:/external/lib -Lc:/external/bin -llibeay32 -lssleay32 -lws2_32 C:/Program Files
(x86)/Lua/5.1/bin/lua51.dll -lm
src/x509.o:x509.c:(.text+0xbc4): undefined reference to `getnameinfo'
collect2.exe: error: ld returned 1 exit status

Error: Build error: Failed compiling module ssl.dll

Press any key to close this window...

I'm travelling for a couple of weeks, so its hard to test for me right now.

@ignacio can you give this a try?

Note: I don't understand the issue. Apparently inet_ntop is defined from Vista onwards, yet on my Win7 system it continues to fail. I understand from @brunoos that it does work with the MS compilers. But I'm using MinGW, with gcc 4.8.1, on Win7 (32bit).

from luasec.

brunoos avatar brunoos commented on July 24, 2024

I tried on WinXP (SP3) with VS 10.
You have to set more symbols:

-DWINVER=0x0501 -D_WIN32_WINNT=0x0501 -DNTDDI_VERSION=0x05010300 -DLUASEC_INET_NTOP

from luasec.

brunoos avatar brunoos commented on July 24, 2024

Again, these defines work for WinXP (SP3)
https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745.aspx

The last time I tested on Win 7 with VS 12, I didn't have to define anything. I will test again.

from luasec.

brunoos avatar brunoos commented on July 24, 2024

gosh, I missed the last part... I will way for more feedback.

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Tried today with VS2008 and WIndows 7, using
luarocks make luasec-0.5-3.rockspec OPENSSL_DIR=c:\OpenSSL-Win32\

It compiles but fails to link:

ssl.def : error LNK2001: unresolved external symbol luaopen_ssl
ssl.lib : fatal error LNK1120: 1 unresolved externals

Error: Build error: Failed compiling module ssl.dll

We need this hack in order to compile with luarocks with MS compilers.

By the way, once the problem with MS compilers is sorted out, I have a PR adding appveyor integration, so we can test using different MS compilers, plus MinGW on Windows.

from luasec.

brunoos avatar brunoos commented on July 24, 2024

Rockspec updated. It seems to work now.

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Sadly, it still won't build with LuaRocks and a MS compiler.

from luasec.

brunoos avatar brunoos commented on July 24, 2024

What is the error?

If you have:

...
link -dll -def:ssl.def -out:ssl.dll C:/devel/lua5.1/lib/lua5.1.lib src/x509.obj
src/context.obj src/ssl.obj src/luasocket/buffer.obj src/luasocket/io.obj src/lu
asocket/timeout.obj src/luasocket/wsocket.obj -libpath:c:\devel\openssl/lib -lib
path:c:\devel\openssl/bin libeay32.lib ssleay32.lib ws2_32.lib
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

ssl.def : error LNK2001: unresolved external symbol luaopen_ssl
ssl.lib : fatal error LNK1120: 1 unresolved externals

Error: Build error: Failed compiling module ssl.dll

It is a LuaRocks issue.

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Yes, that is the error. Could we get this fix added in the meantime?
ignacio@b315a19

I know this is a LuaRocks thing, but it'd really nice to get luasec to build with ms compilers.

from luasec.

brunoos avatar brunoos commented on July 24, 2024

sorry, I will not add this patch to deal with this LuaRocks issue.

I realized that luasec has 6 variations on Windows:

  • WinXP: VS, LuaRocks VS, LuaRocks MinGW (no inet_pton)
  • non-WinXP: VS, LuaRocks VS, LuaRocks MinGW (with inet_pton)

Besides, we have linux, osx and *bsd.

I will not add workarounds to deal with build tools in the code if it is not luasec fault.

This is a patch to luarocks that add an "exports" field, which informs the modules that must be exported from DLL.

--- builtin.old.lua 2015-08-29 08:18:07.000000000 -0300
+++ builtin.lua 2015-08-29 08:26:28.000000000 -0300
@@ -106,7 +106,7 @@
          add_flags(extras, "-I%s", incdirs)
          return execute(variables.CC.." "..variables.CFLAGS, "-c", "-Fo"..object, "-I"..variables.LUA_INCDIR, source, unpack(extras))
       end
-      compile_library = function(library, objects, libraries, libdirs, name)
+      compile_library = function(library, objects, libraries, libdirs, name, exports)
          local extras = { unpack(objects) }
          add_flags(extras, "-libpath:%s", libdirs)
          add_flags(extras, "%s.lib", libraries)
@@ -114,7 +114,13 @@
          local deffile = basename .. ".def"
          local def = io.open(dir.path(fs.current_dir(), deffile), "w+")
          def:write("EXPORTS\n")
-         def:write("luaopen_"..name:gsub("%.", "_").."\n")
+         if exports then
+            for i, module in ipairs(exports) do
+               def:write("luaopen_"..module:gsub("%.", "_").."\n")
+            end
+         else
+            def:write("luaopen_"..name:gsub("%.", "_").."\n")
+         end
          def:close()
          local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras))
          local basedir = ""
@@ -244,7 +250,7 @@
             if not ok then return nil, err end
          end
          built_modules[module_name] = dir.path(libdir, module_name)
-         ok = compile_library(module_name, objects, info.libraries, info.libdirs, name)
+         ok = compile_library(module_name, objects, info.libraries, info.libdirs, name, info.exports)
          if not ok then
             return nil, "Failed compiling module "..module_name
          end

Using with rockspec:

      windows = {
         install = {
            lib = {
               "ssl.dll"
            },
            lua = {
               "src/ssl.lua", ['ssl.https'] = "src/https.lua"
            }
         },
         modules = {
            ssl = {
               defines = {
                  "WIN32", "NDEBUG", "_WINDOWS", "_USRDLL", "LSEC_EXPORTS", "BUFFER_DEBUG", "LSEC_API=__declspec(dllexport)",
                  "LUASEC_INET_NTOP", "WINVER=0x0501", "_WIN32_WINNT=0x0501", "NTDDI_VERSION=0x05010300"
               },
               libdirs = {
                  "$(OPENSSL_LIBDIR)",
                  "$(OPENSSL_BINDIR)",
               },
               libraries = {
                  "libeay32", "ssleay32", "ws2_32"
               },
               incdirs = {
                  "$(OPENSSL_INCDIR)", "src/", "src/luasocket"
               },
               sources = {
                  "src/x509.c", "src/context.c", "src/ssl.c",
                  "src/luasocket/buffer.c", "src/luasocket/io.c",
                  "src/luasocket/timeout.c", "src/luasocket/wsocket.c"
               },
               exports = { "ssl.core", "ssl.context", "ssl.x509" }
            }
         }
      }

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Fair enough.
Since this is an issue with the build tool (luarocks), would you consider supporting LR + Visual Studio by means of a patch in the rockspec?
I can submit a PR if you're willing to approve it.

Thanks for the patch above. Would you mind submitting it to LuaRocks? There is an issue here were this matter has been discussed.

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Ah, also, while in the process of setting up a continuous integration server (appveyor) I found that the mingw build is failing with this error:

In file included from c:\mingw\include\_mingw.h:35:0,
                 from c:\mingw\include\string.h:29,
                 from src/x509.c:9:
c:\mingw\include\sdkddkver.h:137:8: error: #error The _WIN32_WINNT value does not match NTDDI_VERSION
 #      error The _WIN32_WINNT value does not match NTDDI_VERSION
        ^

It seems that it is using mingw 4.8.2 (http://www.appveyor.com/docs/installed-software#mingw-msys-cygwin).

If I edit the rockspec and only add this defines:

defines = {
  "WIN32", "NDEBUG", "_WINDOWS", "_USRDLL", "LSEC_EXPORTS", "BUFFER_DEBUG", "LSEC_API=__declspec(dllexport)",
  "LUASEC_INET_NTOP", "_WIN32_WINNT=0x0501"
}

the it compiles ok. What would be the minimum mingw version that is supported?

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Hi. Any thoughts on this? I'm talking about the possibility of having a patch in the rockspec to support MS compilers. Would you accept a PR for that?

from luasec.

brunoos avatar brunoos commented on July 24, 2024

I can add the "defines" without problem.
Will Luarocks support it?

from luasec.

ignacio avatar ignacio commented on July 24, 2024

About the "defines", I'll need @Tieske thoughts on this since he is more knowledgeable on all things mingw.

I was also talking about adding a patch in the rockspec, to let luasec compile with MS compilers. Could you add that too to the rockspec if I sent you the required changes?

from luasec.

brunoos avatar brunoos commented on July 24, 2024

Yes, I add.

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Hi @brunoos
I've just sent a PR that adds the patch to fix the linking issue when installing with LuaRocks and using Microsoft compilers.

I did not change anything to the defines because mingw is not my area of expertise and I'm afraid I can break something inadvertently.

from luasec.

Tieske avatar Tieske commented on July 24, 2024

I just tried luarocks make from the repository root, it picked the 0.6alpha rockspec and build it properly (using the MinGW toolchain).

seems to work just fine

from luasec.

ignacio avatar ignacio commented on July 24, 2024

Great to hear that, @Tieske
Which version is your mingw install?

from luasec.

Tieske avatar Tieske commented on July 24, 2024

frankly I don't have a clue... gcc reports 4.8.1 (it's 32 bit)

from luasec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.