我如何在 windows 上为 32 位和 64 位目标编译 JNA 的本机位?
How can I compile JNA's native bits on windows for 32- and 64-bit targets?
我想在 32 位 Cygwin 或 32 位 Debian Linux 上使用 -Dskip-native=false 参数编译 JNA 库。我安装了所需的包,但无法编译。它可以在 64 位 Cygwin 或 64 位 Debian Linux 上编译,没有任何问题(针对 64 位目标),但不能在 32 位平台上编译。我还尝试编译 jna-4.2.1/dist/src-full 文件夹中的源代码,但无法编译。
我对 32 位目标使用以下参数。
export ANT_OPTS="-d32 -Dos.prefix=win32-x86 -Dskip-native=false"
我在 64 位 Cygwin(使用相同的参数)上收到以下错误消息。
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S: Assembler messages:
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:286: Error: bad register name `%r11'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:288: Error: bad register name `%rcx'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:291: Error: bad register name `%rsp)'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:294: Error: bad register name `%r11'
...
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:516: Error: bad register name `%rbp'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:517: Error: unsupported instruction `ret'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:518: Warning: zero assumed for missing expression
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:518: Warning: zero assumed for missing expression
[exec] Makefile:1345: recipe for target 'src/x86/win64.lo' failed
[exec] make[3]: Leaving directory '/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi'
[exec] Makefile:1603: recipe for target 'all-recursive' failed
[exec] make[2]: Leaving directory '/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi'
[exec] Makefile:741: recipe for target 'all' failed
[exec] make[1]: Leaving directory '/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi'
[exec] Makefile:449: recipe for target '../build/native-win32-x86/libffi/.libs/libffi.a' failed
[exec] make[3]: *** [src/x86/win64.lo] Error 1
[exec] make[2]: *** [all-recursive] Error 1
[exec] make[1]: *** [all] Error 2
[exec] make: *** [../build/native-win32-x86/libffi/.libs/libffi.a] Error 2
BUILD FAILED
D:\Projects\jna-4.2.1\dist\src-full\build.xml:813: exec returned: 2
我在 32 位 Cygwin 上遇到以下错误。
[echo] os.prefix=win32-x86
[echo] os.name=Windows 7
[echo] os.arch=x86 (little)
[echo] build=build
[echo] build.native=D:\Projects\jna-4.2.1\dist\src-full\build\native-win32-x86
-setup:
compile:
[javac] Compiling 59 source files to D:\Projects\jna-4.2.1\dist\src-full\build\classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 warning
javah:
-native-api-check:
:rsrc:
rsrc:
[copy] Copying 1 file to D:\Projects\jna-4.2.1\dist\src-full\build\native-win32-x86
native:
[exec] Generating configure
[exec] autoreconf-2.69: Entering directory `.'
[exec] autoreconf-2.69: configure.ac: not using Gettext
[exec] autoreconf-2.69: running: aclocal --force -I m4
[exec] autoreconf-2.69: configure.ac: tracing
[exec] autoreconf-2.69: running: libtoolize --copy --force
[exec] libtoolize: putting auxiliary files in '.'.
[exec] libtoolize: copying file './ltmain.sh'
[exec] libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
[exec] libtoolize: copying file 'm4/libtool.m4'
[exec] libtoolize: copying file 'm4/ltoptions.m4'
[exec] libtoolize: copying file 'm4/ltsugar.m4'
[exec] libtoolize: copying file 'm4/ltversion.m4'
[exec] libtoolize: copying file 'm4/lt~obsolete.m4'
[exec] autoreconf-2.69: running: /usr/bin/autoconf-2.69 --force
[exec] autoreconf-2.69: running: /usr/bin/autoheader-2.69 --force
[exec] autoreconf-2.69: running: automake --add-missing --copy --force-missing
[exec] Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake-1.15 line 3936.
[exec] configure.ac:31: installing './compile'
[exec] configure.ac:19: installing './missing'
[exec] Makefile.am: installing './depcomp'
[exec] Configuring libffi (x86)
[exec] autoreconf-2.69: Leaving directory `.'
[exec] checking build system type... i686-pc-cygwin
[exec] checking host system type... i686-pc-cygwin
[exec] checking target system type... i686-pc-cygwin
[exec] checking for gsed... sed
[exec] checking for a BSD-compatible install... /usr/bin/install -c
[exec] checking whether build environment is sane... yes
[exec] checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
[exec] checking for gawk... gawk
[exec] checking whether make sets $(MAKE)... yes
[exec] checking whether make supports nested variables... yes
[exec] checking for gcc... i686-pc-mingw32-gcc
[exec] checking whether the C compiler works... no
[exec] configure: error: in `/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi':
[exec] configure: error: C compiler cannot create executables
[exec] See `config.log' for more details
[exec] Makefile:449: recipe for target '../build/native-win32-x86/libffi/.libs/libffi.a' failed
[exec] make: *** [../build/native-win32-x86/libffi/.libs/libffi.a] Error 77
BUILD FAILED
D:\Projects\jna-4.2.1\dist\src-full\build.xml:813: exec returned: 2
Total time: 50 seconds
虽然我在 32 位 Cygwin 上安装了所有开发包和 lib 包,但 gcc 可以工作,但我不明白为什么它说“[exec] 检查 C 编译器是否工作...不”。
如何为 32 位平台编译 jna 的本地库?
根据 config.log
,configure
在这里失败了:
/cygdrive/d/Projects/jna-4.2.1/native/libffi/configure: line 3927: i686-pc-mingw32-gcc: command not found
确保您的交叉编译器在您的路径上或将 CC=/path/to/your-cross-compiler
添加到 FFI_CONFIG
。
我想在 32 位 Cygwin 或 32 位 Debian Linux 上使用 -Dskip-native=false 参数编译 JNA 库。我安装了所需的包,但无法编译。它可以在 64 位 Cygwin 或 64 位 Debian Linux 上编译,没有任何问题(针对 64 位目标),但不能在 32 位平台上编译。我还尝试编译 jna-4.2.1/dist/src-full 文件夹中的源代码,但无法编译。
我对 32 位目标使用以下参数。
export ANT_OPTS="-d32 -Dos.prefix=win32-x86 -Dskip-native=false"
我在 64 位 Cygwin(使用相同的参数)上收到以下错误消息。
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S: Assembler messages:
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:286: Error: bad register name `%r11'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:288: Error: bad register name `%rcx'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:291: Error: bad register name `%rsp)'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:294: Error: bad register name `%r11'
...
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:516: Error: bad register name `%rbp'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:517: Error: unsupported instruction `ret'
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:518: Warning: zero assumed for missing expression
[exec] /cygdrive/d/Projects/jna-4.2.1/dist/src-full/native/libffi/src/x86/win64.S:518: Warning: zero assumed for missing expression
[exec] Makefile:1345: recipe for target 'src/x86/win64.lo' failed
[exec] make[3]: Leaving directory '/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi'
[exec] Makefile:1603: recipe for target 'all-recursive' failed
[exec] make[2]: Leaving directory '/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi'
[exec] Makefile:741: recipe for target 'all' failed
[exec] make[1]: Leaving directory '/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi'
[exec] Makefile:449: recipe for target '../build/native-win32-x86/libffi/.libs/libffi.a' failed
[exec] make[3]: *** [src/x86/win64.lo] Error 1
[exec] make[2]: *** [all-recursive] Error 1
[exec] make[1]: *** [all] Error 2
[exec] make: *** [../build/native-win32-x86/libffi/.libs/libffi.a] Error 2
BUILD FAILED
D:\Projects\jna-4.2.1\dist\src-full\build.xml:813: exec returned: 2
我在 32 位 Cygwin 上遇到以下错误。
[echo] os.prefix=win32-x86
[echo] os.name=Windows 7
[echo] os.arch=x86 (little)
[echo] build=build
[echo] build.native=D:\Projects\jna-4.2.1\dist\src-full\build\native-win32-x86
-setup:
compile:
[javac] Compiling 59 source files to D:\Projects\jna-4.2.1\dist\src-full\build\classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 warning
javah:
-native-api-check:
:rsrc:
rsrc:
[copy] Copying 1 file to D:\Projects\jna-4.2.1\dist\src-full\build\native-win32-x86
native:
[exec] Generating configure
[exec] autoreconf-2.69: Entering directory `.'
[exec] autoreconf-2.69: configure.ac: not using Gettext
[exec] autoreconf-2.69: running: aclocal --force -I m4
[exec] autoreconf-2.69: configure.ac: tracing
[exec] autoreconf-2.69: running: libtoolize --copy --force
[exec] libtoolize: putting auxiliary files in '.'.
[exec] libtoolize: copying file './ltmain.sh'
[exec] libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
[exec] libtoolize: copying file 'm4/libtool.m4'
[exec] libtoolize: copying file 'm4/ltoptions.m4'
[exec] libtoolize: copying file 'm4/ltsugar.m4'
[exec] libtoolize: copying file 'm4/ltversion.m4'
[exec] libtoolize: copying file 'm4/lt~obsolete.m4'
[exec] autoreconf-2.69: running: /usr/bin/autoconf-2.69 --force
[exec] autoreconf-2.69: running: /usr/bin/autoheader-2.69 --force
[exec] autoreconf-2.69: running: automake --add-missing --copy --force-missing
[exec] Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake-1.15 line 3936.
[exec] configure.ac:31: installing './compile'
[exec] configure.ac:19: installing './missing'
[exec] Makefile.am: installing './depcomp'
[exec] Configuring libffi (x86)
[exec] autoreconf-2.69: Leaving directory `.'
[exec] checking build system type... i686-pc-cygwin
[exec] checking host system type... i686-pc-cygwin
[exec] checking target system type... i686-pc-cygwin
[exec] checking for gsed... sed
[exec] checking for a BSD-compatible install... /usr/bin/install -c
[exec] checking whether build environment is sane... yes
[exec] checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
[exec] checking for gawk... gawk
[exec] checking whether make sets $(MAKE)... yes
[exec] checking whether make supports nested variables... yes
[exec] checking for gcc... i686-pc-mingw32-gcc
[exec] checking whether the C compiler works... no
[exec] configure: error: in `/cygdrive/d/Projects/jna-4.2.1/dist/src-full/build/native-win32-x86/libffi':
[exec] configure: error: C compiler cannot create executables
[exec] See `config.log' for more details
[exec] Makefile:449: recipe for target '../build/native-win32-x86/libffi/.libs/libffi.a' failed
[exec] make: *** [../build/native-win32-x86/libffi/.libs/libffi.a] Error 77
BUILD FAILED
D:\Projects\jna-4.2.1\dist\src-full\build.xml:813: exec returned: 2
Total time: 50 seconds
虽然我在 32 位 Cygwin 上安装了所有开发包和 lib 包,但 gcc 可以工作,但我不明白为什么它说“[exec] 检查 C 编译器是否工作...不”。
如何为 32 位平台编译 jna 的本地库?
根据 config.log
,configure
在这里失败了:
/cygdrive/d/Projects/jna-4.2.1/native/libffi/configure: line 3927: i686-pc-mingw32-gcc: command not found
确保您的交叉编译器在您的路径上或将 CC=/path/to/your-cross-compiler
添加到 FFI_CONFIG
。