frekky / iodine

iodine fork to improve performance and add features
45 stars 12 forks source link

How to Cross-Build for Windows #24

Open Seji64 opened 6 years ago

Seji64 commented 6 years ago

Hello,

can someone give me some tips on how to compile a Windows binary on Linux?

I am using Debian 9 and have tried the following:

Then I get the following error:

make  all-am
make[1]: Verzeichnis „/opt/iodine“ wird betreten
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I.  -DWINDOWS32  -pedantic -O3 -fno-strict-aliasing  -MT src/iodine-common.o -MD -MP -MF src/.deps/iodine-common.Tpo -c -o src/iodine-common.o `test -f 'src/common.c' || echo './'`src/common.c
In file included from src/common.c:19:0:
./config.h:234:19: error: two or more data types in declaration specifiers
 #define socklen_t int
                   ^
In file included from src/common.c:58:0:
src/common.h:64:0: warning: "BITS_64" redefined
 #define BITS_64 1

src/common.h:56:0: note: this is the location of the previous definition
 #define BITS_64

src/common.c: In function ‘socket_set_blocking’:
src/common.c:415:31: warning: passing argument 3 of ‘ioctlsocket’ from incompatible pointer type [-Wincompatible-pointer-types]
  if (ioctlsocket(fd, FIONBIO, &blocking) != 0) {
                               ^
In file included from src/common.c:37:0:
/usr/share/mingw-w64/include/winsock2.h:977:34: note: expected ‘u_long * {aka long unsigned int *}’ but argument is of type ‘int *’
   WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
                                  ^~~~~~~~~~~
src/common.c: In function ‘check_tcp_error’:
src/common.c:469:43: warning: passing argument 4 of ‘getsockopt’ from incompatible pointer type [-Wincompatible-pointer-types]
  if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &errornum, &len) != 0) {
                                           ^
In file included from src/common.c:37:0:
/usr/share/mingw-w64/include/winsock2.h:980:34: note: expected ‘char *’ but argument is of type ‘int *’
   WINSOCK_API_LINKAGE int WSAAPI getsockopt(SOCKET s,int level,int optname,char *optval,int *optlen);
                                  ^~~~~~~~~~
Makefile:969: die Regel für Ziel „src/iodine-common.o“ scheiterte
make[1]: *** [src/iodine-common.o] Fehler 1
make[1]: Verzeichnis „/opt/iodine“ wird verlassen
Makefile:628: die Regel für Ziel „all“ scheiterte
make: *** [all] Fehler 2

It's my first time trying to cross-build so i don't have really a glue....

Thanks in advance

frekky commented 6 years ago

Hi and happy 2018! Currently support is unavailable for Windows which may change in the coming months depending on time and availability of Windows systems to experiment with. Perhaps the most straightforward solution is to run iodine inside a Linux VM (using for example Virtualbox). Good luck!

Lanchon commented 6 years ago

if using windows 10 maybe you don't need a windows build at all. take a look at the Windows Subsystem for Linux.

twumasiandrews commented 6 years ago

Comment out #define socklen_t int in config.h and add "-liphlpapi -lws2_32" to LIBS in makefile. Typecast the variables in the warning to respective types in common.h(not necessary, clears the warnings). At least the iodine client compiles without errors by doing the above.

Anime4000 commented 6 years ago

@Seji64 I did compile this version of iodine... you can see log here: https://gist.github.com/Anime4000/03bb3d18b0cfdfa9e2439e3dc045d0c2