hyperboria / bugs

Peer-to-peer IPv6 networking, secure and near-zero-conf.
153 stars 17 forks source link

Can't compile Windows executables on Ubuntu 22.04 #203

Open andrasfuchs opened 2 years ago

andrasfuchs commented 2 years ago

I tried to compile the CJDNS source for Windows on Ubuntu with the following commands:

sudo apt-get install mingw-w64 build-essential nodejs git

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

git clone https://github.com/cjdelisle/cjdns.git
cd cjdns

SYSTEM=win32 CROSS_COMPILE=i686-w64-mingw32- ./cross-do

I got back this:

Using i686-w64-mingw32-gcc (GCC) 10-win32 20220113 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler CC: i686-w64-mingw32-gcc
Compiler CFLAGS:
Compiler LDFLAGS:
   Compiling libsodium-sys v0.2.6 (https://github.com/cjdelisle/sodiumoxide?branch=cjdns#3aa7e8e2)
   Compiling cjdns_sys v0.1.0 (/home/andras/cjdns/rust/cjdns_sys)
error: failed to run custom build command for `cjdns_sys v0.1.0 (/home/andras/cjdns/rust/cjdns_sys)`

Caused by:
  process didn't exit successfully: `/home/andras/cjdns/target/release/build/cjdns_sys-6dbc8e88e4cae3eb/build-script-build` (exit status: 1)
  --- stdout
  Initialize 3ms
  testing python python3.7
  error starting python Error: spawn python3.7 ENOENT
  testing python python3
  sys.version_info(major=3, minor=10, micro=4, releaselevel='final', serial=0)

  Build Libuv
  Total build time: 174ms.

  --- stderr
  /home/andras/cjdns/node_build/CjdnsTest.js:36
          if (err) { throw err; }
                     ^

  Error: ENOENT: no such file or directory, stat './node_linux/nodejs/node/include/node/openssl/archs/BSD-x86'
      at Error (native)
  Error: Failed to build cjdns
  Traceback (most recent call last):
    File "/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/./gyp_uv.py", line 14, in <module>
      import gyp
    File "/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/build/gyp/pylib/gyp/__init__.py", line 10, in <module>
      import gyp.input
    File "/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/build/gyp/pylib/gyp/input.py", line 8, in <module>
      import gyp.common
    File "/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/build/gyp/pylib/gyp/common.py", line 497, in <module>
      class OrderedSet(collections.MutableSet):
  AttributeError: module 'collections' has no attribute 'MutableSet'
warning: build failed, waiting for other jobs to finish...
error: build failed

I don't completely understand the error, it might be because of a breaking change between Python 3.9 and 3.10? I have Python 3.10 installed on WSL Ubuntu 22.04.

andrasfuchs commented 2 years ago

I managed to install Python 3.7 with these commands:

sudo apt install software-properties-common -y

sudo add-apt-repository ppa:deadsnakes/ppa -y

sudo apt update

sudo apt-get install mingw-w64 build-essential nodejs git python3.7

ls /usr/bin/python* -l

sudo ln -vfns /usr/bin/python3.7 /usr/bin/python3

When I run SYSTEM=win32 CROSS_COMPILE=i686-w64-mingw32- ./cross-do again, I got a different error:

Using i686-w64-mingw32-gcc (GCC) 10-win32 20220113 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler CC: i686-w64-mingw32-gcc
Compiler CFLAGS:
Compiler LDFLAGS:
   Compiling libsodium-sys v0.2.6 (https://github.com/cjdelisle/sodiumoxide?branch=cjdns#3aa7e8e2)
   Compiling cjdns_sys v0.1.0 (/home/andras/cjdns/rust/cjdns_sys)
error: failed to run custom build command for `cjdns_sys v0.1.0 (/home/andras/cjdns/rust/cjdns_sys)`

Caused by:
  process didn't exit successfully: `/home/andras/cjdns/target/release/build/cjdns_sys-6dbc8e88e4cae3eb/build-script-build` (exit status: 1)
  --- stdout
  Initialize 3ms
  testing python python3.7
  sys.version_info(major=3, minor=7, micro=13, releaselevel='final', serial=0)

  Build Libuv
  Total build time: 112ms.
  ['-DOS=win', '-f', 'make-linux', '/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/uv.gyp', '-I', '/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/common.gypi', '--depth=.', '-Goutput_dir=/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/out', '--generator-output', '/home/andras/cjdns/target/release/build/cjdns_sys-3ae9253361d09334/out/dependencies/libuv/out', '-Dhost_arch=x64', '-Dtarget_arch=x64', '-Dlibrary=static_library', '-Dcomponent=static_library']

  --- stderr
  /home/andras/cjdns/node_build/CjdnsTest.js:36
          if (err) { throw err; }
                     ^

  Error: ENOENT: no such file or directory, stat './node_linux/nodejs/node/include/node/libplatform/libplatform.h'
      at Error (native)
  Error: Failed to build cjdns
warning: build failed, waiting for other jobs to finish...
error: build failed

Interestingly nano ./node_linux/nodejs/node/include/node/libplatform/libplatform.h could open that file without any problems.

andrasfuchs commented 2 years ago

After the steps above I could build the Windows executables using ./windows_do.

In order to use these files on Windows you must also get the libssp-0.dll from the LLVM based mingw-w64 toolchain repo.

It would be great to update the CJDNS Windows documentation based on these results.