如何在Windows上为32位和64位目标编译JNA的本机位?

时间:2016-03-22 06:37:03

标签: jna

我想使用-Dskip-native = false参数在32位Cygwin或32位Debian Linux上编译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

我无法理解为什么它说&#34; [exec]检查C编译器是否正常工作......没有&#34;虽然我在32位Cygwin上安装了所有开发包和lib包,虽然gcc可以工作。

如何为32位平台编译jna的本机库?

1 个答案:

答案 0 :(得分:0)

根据config.logconfigure失败了:

/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