shadowsocks / shadowsocks-libev

Bug-fix-only libev port of shadowsocks. Future development moved to shadowsocks-rust
https://github.com/shadowsocks/shadowsocks-rust
GNU General Public License v3.0
15.81k stars 5.69k forks source link

Broken build in Mingw #2915

Open artenax opened 2 years ago

artenax commented 2 years ago

The version from this commit is not built in Mingw. I am using Debian 11 i386. Not Docker, manually. Mingw 10.2. The versions of self-builded libraries roughly match the versions from docker/mingw/prepare.sh file. libev 4.25, mbedtls 2.16.5, libsodium 1.0.18, pcre 8.44, c-ares 1.16. shadows-locks-libev 3.3.5 builds up to commit c2fc967c1a3e4d864d866cc92dd29a04cdb11f98, but then error when building ss_local-udprelay.o:

  CC       ss_local-udprelay.o
udprelay.c: In function ‘convert_ipv4_mapped_ipv6’:
udprelay.c:759:9: error: unknown type name ‘in_addr_t’; did you mean ‘ss_addr_t’?
  759 |         in_addr_t ipv4_raw_addr = ntohl(ipv4_addr->sin_addr.s_addr);
      |         ^~~~~~~~~
      |         ss_addr_t
make[2]: *** [Makefile:1086: ss_local-udprelay.o] Error 1
make[2]: выход из каталога «/home/denis/shadowsocks-libev/src»
make[1]: *** [Makefile:489: all-recursive] Error 1
make[1]: выход из каталога «/home/denis/shadowsocks-libev»
make: *** [Makefile:398: all] Error 2

Including the latest git. By the way, the patched version of libev 4.24-mingw doesn't pass ./configure (loop ev check doesn't pass), so I used the vanilla libev 4.25, but that doesn't matter here. And some URLs in prepare.sh are not available and I had to look for alternatives.

However, the native shared linux build (latest git) builds even in ubuntu 16.04 with gcc5.

artenax commented 2 years ago

Here are the build instructions.

artenax commented 2 years ago

Anyway, even compiled executables don't run (on Windows 7 and Wine).

dongzhaosheng73 commented 1 year ago

I had the same problem. How do I use this fix pack? Can you fix the compilation problem with this? https://github.com/shadowsocks/libev/archive/mingw.zip

N-Storm commented 1 month ago

It's an old issue, but anyways... This patch makes most recent trunk version build under native Windows/MSYS2 (tested with UCRT64, but I guess MINGW64 should result the same). But it segfaults if I try to connect to anything.

--- a/src/udprelay.c
+++ b/src/udprelay.c
@@ -27,6 +27,7 @@
 #include <signal.h>
 #include <string.h>
 #include <strings.h>
+#include <stdint.h>
 #include <time.h>
 #include <unistd.h>
 #ifndef __MINGW32__
@@ -35,6 +36,9 @@
 #include <netdb.h>
 #include <netinet/in.h>
 #include <pthread.h>
+#else
+#include <winsock.h>
+#define in_addr_t u_long
 #endif
 #ifdef HAVE_CONFIG_H
 #include "config.h"
diff --git a/src/utils.h b/src/utils.h
index 1df24c1..bfaabaa 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -193,8 +193,8 @@ extern int use_syslog;

 // Workaround for "%z" in Windows printf
 #ifdef __MINGW32__
-#define SSIZE_FMT "%Id"
-#define SIZE_FMT "%Iu"
+#define SSIZE_FMT "%Illd"
+#define SIZE_FMT "%Illu"
 #else
 #define SSIZE_FMT "%zd"
 #define SIZE_FMT "%zu"
dongzhaosheng73 commented 3 weeks ago

You can't compile smoothly on windows without relying on docker. At least I haven't succeeded so far.

@.***

From: N-Storm Date: 2024-09-16 22:07 To: shadowsocks/shadowsocks-libev CC: dongzhaosheng73; Comment Subject: Re: [shadowsocks/shadowsocks-libev] Broken build in Mingw (Issue #2915) It's an old issue, but in case anyone still wondering how to build for Windows without docker. This trick helped me to build under native Windows/MSYS2-UCRT64: --- a/src/udprelay.c +++ b/src/udprelay.c @@ -27,6 +27,7 @@

include

include

include

+#include

include

include

ifndef MINGW32

@@ -35,6 +36,9 @@

include

include <netinet/in.h>

include

+#else +#include +#define in_addr_t u_long

endif

ifdef HAVE_CONFIG_H

include "config.h"

diff --git a/src/utils.h b/src/utils.h index 1df24c1..bfaabaa 100644 --- a/src/utils.h +++ b/src/utils.h @@ -193,8 +193,8 @@ extern int use_syslog; // Workaround for "%z" in Windows printf

ifdef MINGW32

-#define SSIZE_FMT "%Id" -#define SIZE_FMT "%Iu" +#define SSIZE_FMT "%Illd" +#define SIZE_FMT "%Illu"

else

define SSIZE_FMT "%zd"

define SIZE_FMT "%zu"

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>