Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active October 30, 2020 02:52
Show Gist options
  • Save tresf/d07a3d78020a5fa1d238fe75c2f323e5 to your computer and use it in GitHub Desktop.
Save tresf/d07a3d78020a5fa1d238fe75c2f323e5 to your computer and use it in GitHub Desktop.
Building JNA on Windows ARM64

Building JNA on Windows 10 for ARM64:

  1. Using Windows 10 on ARM, Install Visual Studio with ARM compiler support

  2. Manually install and configure ANT with Microsoft's experimental ARM Java build https://github.com/microsoft/openjdk-aarch64/releases

  3. Download the x86 version of Cygwin (the 64-bit version will NOT run on ARM64)

  4. Take the defaults

  5. When prompted select a reputable mirror (e.g. for US: https://mirrors.rit.edu)

  6. Cygwin will ask for packages. Many required packages are provided by default (shell, sed, grep) however the following must be manually selected:

    make
    automake
    libtool
    dos2unix
    # for x86_64, you would also need mingw64-g++
  7. (TODO: Verify) Update libffi dependency to latest with arm64 support

    cd build\native
    mv libffi libffi_old
    git clone https://github.com/libffi/libffi
  8. Open the Cygwin Terminal and convert *.am and *.sh files to UNIX format:

    find . -name \*.ac|xargs dos2unix
    find . -name \*.am|xargs dos2unix
    find . -name \*.sh|xargs dos2unix
    find . -name \*.sub|xargs dos2unix
    find . -name \*.guess|xargs dos2unix
    find . -name \*.host|xargs dos2unix
    find . -name libtool-\*|xargs dos2unix
  9. Open CMD and source the MSVC environment providing -host_arch=x86 and -arch=arm64

    "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd" -arch=arm64 -host_arch=x86
  10. Add \cygwin\bin to your path

    set PATH=%SystemDrive%\cygwin64\bin\;%SystemDrive%\cygwin\bin;%PATH%
  11. Start the build with verbosity (--debug=v) enabled

    ant native -DEXTRA_MAKE_OPTS="--debug=v"

Broken, Help Wanted

Click for full logs: https://gist.github.com/tresf/c88a365f4269adeb011f6e64cec5e9bb

     [exec]  Assembling: src/x86/win32.asm
     [exec]     Successfully remade target file 'src/x86/win32.lo'.
     [exec]   Must remake target 'libffi_convenience.la'.
     [exec] /bin/sh ./libtool  --tag=CC   --mode=link /cygdrive/c/Users/Administrator/jna/native/libffi/msvcc.sh  -warn all   -o libffi_convenience.la  src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.lo src/closures.lo      src/x86/ffi.lo src/x86/win32.lo
     [exec] libtool: link: lib -OUT:.libs/ffi_convenience.lib  src/prep_cif.obj src/types.obj src/raw_api.obj src/java_raw_api.obj src/closures.obj src/x86/ffi.obj src/x86/win32.obj
     [exec] Microsoft (R) Library Manager Version 14.26.28806.0
     [exec] Copyright (C) Microsoft Corporation.  All rights reserved.
     [exec]
     [exec] src\x86\win32.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'ARM64'
     [exec] make[3]: Leaving directory '/cygdrive/c/Users/Administrator/jna/build/native-win32-aarch64/libffi'
     [exec] make[2]: Leaving directory '/cygdrive/c/Users/Administrator/jna/build/native-win32-aarch64/libffi'
     [exec] make[1]: Leaving directory '/cygdrive/c/Users/Administrator/jna/build/native-win32-aarch64/libffi'
     [exec] make[3]: *** [Makefile:1227: libffi_convenience.la] Error 88
     [exec] make[2]: *** [Makefile:1658: all-recursive] Error 1
     [exec] make[1]: *** [Makefile:790: all] Error 2
     [exec] make: *** [Makefile:483: ../build/native-win32-aarch64/libffi/.libs/libffi.lib] Error 2

BUILD FAILED
C:\Users\Administrator\jna\build.xml:1028: exec returned: 2

Total time: 5 minutes 45 seconds

Keywords: Java Native Access, libffi, msvcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment