-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Hello! I encountered an issue while compiling scr/ssl.c.
I’m installing Luasec via luarocks, and here’s my config:
variables = {
CC = "i686-w64-mingw32-gcc",
OPENSSL_DIR = "C:/OpenSSL-Win32-not-lib-formatted",
OPENSSL_INCDIR = "C:/OpenSSL-Win32-not-lib-formatted/include",
CFLAGS = "-D_WIN32_WINNT=0x0600 -I C:/OpenSSL-Win32-not-lib-formatted/include -I C:/lua/5.4.7/src -I C:/Users/FREERIDE/AppData/Roaming/luarocks/lib/luarocks/luasocket-source",
LIBFLAG = "-shared -lkernel32 -lws2_32 -static-libgcc -static -L C:/OpenSSL-Win32-not-lib-formatted/lib/MinGW/x86 -L C:/lua/5.4.7/src",
}First, let's start with something else.
I added the path C:/Users/FREERIDE/AppData/Roaming/luarocks/lib/luarocks/luasocket-source (luasocket source) to CFLAGS when trying to compile luasec manually. I encountered errors related to luasocket (as I understand, if you compile luasec manually, you’ll also need the luasocket source code).
So I downloaded the luasocket source code and even had to rename its scr folder to luasocket so that ssl.c in luasec could find files inside the luasocket source.
To my surprise, I also had to add this path in the config when downloading via luarocks. This is very strange, and here's why:
First of all, if I didn't add this path when installing via luarocks, I would get errors like:
mingw32-gcc -shared -lkernel32 -lws2_32 -static-libgcc -static -L C:/OpenSSL-Win32-not-lib-formatted/lib/MinGW/x86 -L C:/lua/5.4.7/src
-o C:\Users\FREERIDE\AppData\Local\Temp\luarocks_build-LuaSec-1.3.2-1-2827520\ssl.dll src/options.o src/config.o src/ec.o src/x509.o src/context.o src/ssl.o src/luasocket/buffer.o src/luasocket/io.o src/luasocket/timeout.o src/luasocket/wsocket.o -LC:\OpenSSL-Win32-not-lib-formatted\lib -LC:\OpenSSL-Win32-not-lib-formatted\bin -llibssl -llibcrypto -lws2_32 C:\lua\5.4.7\src\lua54.dll -lm
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibssl
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibcrypto
collect2.exe: error: ld returned 1 exit status
Error: Build error: Failed compiling module ssl.dllThe question is: why do these errors even occur if I explicitly specify the paths to the openssl directories?
And how is this even related?
If I add that path to CFLAGS, it somehow fixes the issue where luarocks can't find libssl and libcrypto.
And in general, I thought that when installing luasec, luarocks would not need the luasocket source code because I already have luasocket installed!
Yes, luasec depends on luasocket, but not to the extent that it would need the full luasocket source.
Even if luarocks needs the luasocket source when installing luasec, then wth doesn't it fetch it from somewhere by itself?!
In what way am i supposed to guess that it needs the luasocket source code?
Now let's move on to the main issue since the previous one was solved in an unclear way.
I had to try so many things just to end up using the i686-w64-mingw32-gcc C compiler version.
But now I have a completely different problem that I have no idea how to solve.
Here are all the errors that occur:
<command-line>: warning: "_WIN32_WINNT" redefined # There are many more such warnings due to the fact that my version of OpenSSL is new
<command-line>: note: this is the location of the previous definition
src/ssl.c: In function 'handshake':
src/ssl.c:131:39: error: 'WAITFD_R' undeclared (first use in this function); did you mean 'DATADIR'?
err = socket_waitfd(&ssl->sock, WAITFD_R, tm);
^~~~~~~~
DATADIR
src/ssl.c:131:39: note: each undeclared identifier is reported only once for each function it appears in
src/ssl.c:136:39: error: 'WAITFD_W' undeclared (first use in this function)
err = socket_waitfd(&ssl->sock, WAITFD_W, tm);
^~~~~~~~
src/ssl.c: In function 'ssl_send':
src/ssl.c:175:39: error: 'WAITFD_R' undeclared (first use in this function); did you mean 'DATADIR'?
err = socket_waitfd(&ssl->sock, WAITFD_R, tm);
^~~~~~~~
DATADIR
src/ssl.c:180:39: error: 'WAITFD_W' undeclared (first use in this function)
err = socket_waitfd(&ssl->sock, WAITFD_W, tm);
^~~~~~~~
src/ssl.c: In function 'ssl_recv':
src/ssl.c:221:39: error: 'WAITFD_R' undeclared (first use in this function); did you mean 'DATADIR'?
err = socket_waitfd(&ssl->sock, WAITFD_R, tm);
^~~~~~~~
DATADIR
src/ssl.c:226:39: error: 'WAITFD_W' undeclared (first use in this function)
err = socket_waitfd(&ssl->sock, WAITFD_W, tm);
^~~~~~~~
src/ssl.c: In function 'meth_handshake':
src/ssl.c:394:5: warning: 'DH_free' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
DH_free(ctx->dh_param);
^~~~~~~
In file included from C:/OpenSSL-Win32-not-lib-formatted/include/openssl/dsa.h:31,
from C:/OpenSSL-Win32-not-lib-formatted/include/openssl/x509.h:37,
from C:/OpenSSL-Win32-not-lib-formatted/include/openssl/ssl.h:32,
from src/ssl.c:16:
C:/OpenSSL-Win32-not-lib-formatted/include/openssl/dh.h:211:28: note: declared here
OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh);
^~~~~~~
Error: Build error: Failed compiling object src/ssl.oAs far as I understand, ssl.c cannot find variables that are supposed to be declared by OpenSSL.
Maybe I need to download an older version of OpenSSL?
I have OpenSSL 3.4.1 installed.
If yes, then please tell me which version (32-bit)?
I've been trying to install luasec for two days, but it's not working out well.
I'm just tired and need to rest a little, so i'm reaching out to the community.
Thanks in advance for any help!