Java 库蚂蚁构建 issue/bug 的 GnuPG
GnuPG for Java library ant build issue/bug
我正在 GnuPG Java API
处理 encrypt/decrypt 个文件。
用 Google 搜索并找到 Java Wrapper GnuPG for Java
,Java wrapper for GPGME(GnuPG Made Easy,C language library)
.
官方网站还将 this 称为 Java 包装器。
所以按照说明,设置 ant
并尝试 运行 ant clean release
它正在抛出错误。
但是 maven 构建工作和 jar 文件也生成了。
运行 宁 ant
时发生以下错误。
C:\Users\user\Desktop\MFT\gnupg-for-java-master>ant clean release
Buildfile: C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml
clean-native:
[exec] rm -f GnuPGContext.o GnuPGData.o GnuPGGenkeyResult.o GnuPGKey.o GnuPGSignature.o gpgmeutils.o *~
[exec] rm -f C:\Users\user\Desktop\MFT\gnupg-for-java-master\build/gnupg-for-java.dll
[exec] rm -f com_freiheit_gnupg_GnuPGContext.h com_freiheit_gnupg_GnuPGData.h com_freiheit_gnupg_GnuPGGenkeyResult.h com_freiheit_gnupg_GnuPG
Key.h com_freiheit_gnupg_GnuPGSignature.h
clean:
[delete] Deleting directory C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes
prepare:
compile-java:
[mkdir] Created dir: C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes
[javac] C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:21: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=l
ast; set to false for repeatable builds
[javac] Compiling 8 source files to C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes
gen-jni-headers:
prepare:
compile-java:
[javac] C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:21: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=l
ast; set to false for repeatable builds
generate-jni-headers:
[exec] C:\Program Files (x86)/Java/jdk1.7.0_51/bin/javah -classpath C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes -jni com.freih
eit.gnupg.GnuPGContext com.freiheit.gnupg.GnuPGData com.freiheit.gnupg.GnuPGGenkeyResult com.freiheit.gnupg.GnuPGKey com.freiheit.gnupg.GnuPGSigna
ture
[exec] /bin/sh: -c: line 0: syntax error near unexpected token `('
[exec] /bin/sh: -c: line 0: `C:\Program Files (x86)/Java/jdk1.7.0_51/bin/javah -classpath C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\c
lasses -jni com.freiheit.gnupg.GnuPGContext com.freiheit.gnupg.GnuPGData com.freiheit.gnupg.GnuPGGenkeyResult com.freiheit.gnupg.GnuPGKey com.fre
iheit.gnupg.GnuPGSignature'
[exec] make: *** [com_freiheit_gnupg_GnuPGContext.h] Error 2
BUILD FAILED
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:71: The following error occurred while executing this line:
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:63: exec returned: 2
Total time: 4 seconds
更新
我更改了 GNUmakefile
中的 Java home
,现在它抛出不同的错误。似乎 c library
未找到,并且此 API 是为 Unix 系统编写的,阅读错误消息似乎。缺少什么 C 库?
generate-jni-headers:
[exec] C:\Java\jdk1.7.0_75/bin/javah -classpath C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes -jni com.freiheit.gnupg.GnuPGConte
xt com.freiheit.gnupg.GnuPGData com.freiheit.gnupg.GnuPGGenkeyResult com.freiheit.gnupg.GnuPGKey com.freiheit.gnupg.GnuPGSignature
gen-jni-library:
recompile-c-code:
[exec] mingw32-gcc -g -Werror -Wall -Wno-deprecated-declarations -fPIC -mms-bitfields -Wl,--add-stdcall-alias -D_REENTRANT -D_THREAD_SAFE -D_FIL
E_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 -I"C:\Java\jdk1.7.0_75/include" -I"C:\Java\jdk1.7.0_75/include/win32" -I"C:\Program Files (x86)/GNU/GnuPG/includ
e" -c GnuPGContext.c
[exec] /bin/sh: mingw32-gcc: command not found
[exec] make: *** [GnuPGContext.o] Error 127
BUILD FAILED
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:82: The following error occurred while executing this line:
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:75: exec returned: 2
Total time: 7 seconds
谁能帮我解决这个问题?
我哪里出错了?
我重写了我的答案,因为我想创建一个完整的指南。
安装 GnuPG 和 MinGW-Get 到一个没有空格的目录。
使用 !!!GUI!!! 安装 MinGW 后,打开 mingw-get,安装这些组件:
mingw32-gcc(全部勾选)
mingw32-libz(dll最重要)
Download and install MSYS,这是一个命令行工具包,用于 运行 命令,如 make.
然后将 c:\msys.0\bin\
(或您安装它的任何位置)放在 PATH 变量的开头。重启eclipse或者打开一个新的cmd,应该可以了。
在 build.xml 中:
第 21 行:
classpath="lib/junit-4.4.jar" added.(and the junit is in the lib dir)
在 GNUmake 文件中:
第 9 行:
ALL_CFLAGS := -Wall -Wno-deprecated-declarations -fPIC
第 10 行:
ALL_CPPFLAGS = -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 \
-I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include" -I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include/win32"
第 21-27 行:
JAVA_HOME := c:/WORK/x/gnu/jdk/jdk1.8.0_25
ALL_CFLAGS += -mms-bitfields -Wl,--add-stdcall-alias
ALL_CPPFLAGS += -I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include/win32" -I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include" -I"c:/GNU/GnuPG/include"
ALL_LDFLAGS := -s -shared -Wl,--enable-auto-import
ALL_LIBS := -L"c:/GNU/GnuPG" -lgpgme-11
GNUPG_LIB := $(BUILD_DIR)/gnupg-for-java.dll
第 63 行:
$(CC) $(DEBUG) $(ALL_CFLAGS) $(ALL_LDFLAGS) $^ -o "$(BUILD_DIR)/gnupg-for-java.dll" $(ALL_LIBS)
总结:这对我有用,并将 jar 和 dll 文件输出到构建目录。我的工作目录是 c:/WORK/x 所以替换它不同的路径。不要在任何地方使用 "Program Files",如您所见,我必须从那里复制所有内容。
错误消息表明它无法在 /bin/sh
中找到 mingw32-gcc
。
您应该首先安装 mingw 并将其添加到您的路径中。检查是否可以从命令行启动 mingw32-gcc。
您运行正在使用 cygwin 的 ant 脚本吗?有点奇怪,它指的是/bin/sh
。也许你应该尝试从 cygwin 运行 它。或者查看 build.xml 文件,看看 mingw32-gcc 是如何调用的。它必须是 recompile-c-code 目标。
我正在 GnuPG Java API
处理 encrypt/decrypt 个文件。
用 Google 搜索并找到 Java Wrapper GnuPG for Java
,Java wrapper for GPGME(GnuPG Made Easy,C language library)
.
官方网站还将 this 称为 Java 包装器。
所以按照说明,设置 ant
并尝试 运行 ant clean release
它正在抛出错误。
但是 maven 构建工作和 jar 文件也生成了。
运行 宁 ant
时发生以下错误。
C:\Users\user\Desktop\MFT\gnupg-for-java-master>ant clean release
Buildfile: C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml
clean-native:
[exec] rm -f GnuPGContext.o GnuPGData.o GnuPGGenkeyResult.o GnuPGKey.o GnuPGSignature.o gpgmeutils.o *~
[exec] rm -f C:\Users\user\Desktop\MFT\gnupg-for-java-master\build/gnupg-for-java.dll
[exec] rm -f com_freiheit_gnupg_GnuPGContext.h com_freiheit_gnupg_GnuPGData.h com_freiheit_gnupg_GnuPGGenkeyResult.h com_freiheit_gnupg_GnuPG
Key.h com_freiheit_gnupg_GnuPGSignature.h
clean:
[delete] Deleting directory C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes
prepare:
compile-java:
[mkdir] Created dir: C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes
[javac] C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:21: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=l
ast; set to false for repeatable builds
[javac] Compiling 8 source files to C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes
gen-jni-headers:
prepare:
compile-java:
[javac] C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:21: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=l
ast; set to false for repeatable builds
generate-jni-headers:
[exec] C:\Program Files (x86)/Java/jdk1.7.0_51/bin/javah -classpath C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes -jni com.freih
eit.gnupg.GnuPGContext com.freiheit.gnupg.GnuPGData com.freiheit.gnupg.GnuPGGenkeyResult com.freiheit.gnupg.GnuPGKey com.freiheit.gnupg.GnuPGSigna
ture
[exec] /bin/sh: -c: line 0: syntax error near unexpected token `('
[exec] /bin/sh: -c: line 0: `C:\Program Files (x86)/Java/jdk1.7.0_51/bin/javah -classpath C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\c
lasses -jni com.freiheit.gnupg.GnuPGContext com.freiheit.gnupg.GnuPGData com.freiheit.gnupg.GnuPGGenkeyResult com.freiheit.gnupg.GnuPGKey com.fre
iheit.gnupg.GnuPGSignature'
[exec] make: *** [com_freiheit_gnupg_GnuPGContext.h] Error 2
BUILD FAILED
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:71: The following error occurred while executing this line:
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:63: exec returned: 2
Total time: 4 seconds
更新
我更改了 GNUmakefile
中的 Java home
,现在它抛出不同的错误。似乎 c library
未找到,并且此 API 是为 Unix 系统编写的,阅读错误消息似乎。缺少什么 C 库?
generate-jni-headers:
[exec] C:\Java\jdk1.7.0_75/bin/javah -classpath C:\Users\user\Desktop\MFT\gnupg-for-java-master\build\classes -jni com.freiheit.gnupg.GnuPGConte
xt com.freiheit.gnupg.GnuPGData com.freiheit.gnupg.GnuPGGenkeyResult com.freiheit.gnupg.GnuPGKey com.freiheit.gnupg.GnuPGSignature
gen-jni-library:
recompile-c-code:
[exec] mingw32-gcc -g -Werror -Wall -Wno-deprecated-declarations -fPIC -mms-bitfields -Wl,--add-stdcall-alias -D_REENTRANT -D_THREAD_SAFE -D_FIL
E_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 -I"C:\Java\jdk1.7.0_75/include" -I"C:\Java\jdk1.7.0_75/include/win32" -I"C:\Program Files (x86)/GNU/GnuPG/includ
e" -c GnuPGContext.c
[exec] /bin/sh: mingw32-gcc: command not found
[exec] make: *** [GnuPGContext.o] Error 127
BUILD FAILED
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:82: The following error occurred while executing this line:
C:\Users\user\Desktop\MFT\gnupg-for-java-master\build.xml:75: exec returned: 2
Total time: 7 seconds
谁能帮我解决这个问题? 我哪里出错了?
我重写了我的答案,因为我想创建一个完整的指南。
安装 GnuPG 和 MinGW-Get 到一个没有空格的目录。
使用 !!!GUI!!! 安装 MinGW 后,打开 mingw-get,安装这些组件:
mingw32-gcc(全部勾选)
mingw32-libz(dll最重要)
Download and install MSYS,这是一个命令行工具包,用于 运行 命令,如 make.
然后将 c:\msys.0\bin\
(或您安装它的任何位置)放在 PATH 变量的开头。重启eclipse或者打开一个新的cmd,应该可以了。
在 build.xml 中: 第 21 行:
classpath="lib/junit-4.4.jar" added.(and the junit is in the lib dir)
在 GNUmake 文件中: 第 9 行:
ALL_CFLAGS := -Wall -Wno-deprecated-declarations -fPIC
第 10 行:
ALL_CPPFLAGS = -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 \
-I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include" -I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include/win32"
第 21-27 行:
JAVA_HOME := c:/WORK/x/gnu/jdk/jdk1.8.0_25
ALL_CFLAGS += -mms-bitfields -Wl,--add-stdcall-alias
ALL_CPPFLAGS += -I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include/win32" -I"c:/WORK/x/gnu/jdk/jdk1.8.0_25/include" -I"c:/GNU/GnuPG/include"
ALL_LDFLAGS := -s -shared -Wl,--enable-auto-import
ALL_LIBS := -L"c:/GNU/GnuPG" -lgpgme-11
GNUPG_LIB := $(BUILD_DIR)/gnupg-for-java.dll
第 63 行:
$(CC) $(DEBUG) $(ALL_CFLAGS) $(ALL_LDFLAGS) $^ -o "$(BUILD_DIR)/gnupg-for-java.dll" $(ALL_LIBS)
总结:这对我有用,并将 jar 和 dll 文件输出到构建目录。我的工作目录是 c:/WORK/x 所以替换它不同的路径。不要在任何地方使用 "Program Files",如您所见,我必须从那里复制所有内容。
错误消息表明它无法在 /bin/sh
中找到 mingw32-gcc
。
您应该首先安装 mingw 并将其添加到您的路径中。检查是否可以从命令行启动 mingw32-gcc。
您运行正在使用 cygwin 的 ant 脚本吗?有点奇怪,它指的是/bin/sh
。也许你应该尝试从 cygwin 运行 它。或者查看 build.xml 文件,看看 mingw32-gcc 是如何调用的。它必须是 recompile-c-code 目标。