我正在GnuPG Java API
加密/解密文件
用Google搜索并找到了一个Java Wrapper GnuPG for Java
,GPGME(GnuPG Made Easy,C language library)
的Java包装器
官方网站还将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
更新
我更改了Java home
中的GNUmakefile
,现在它抛出了不同的错误。似乎没有找到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
有人可以帮我解决这个问题吗? 我在哪里弄错了?
答案 0 :(得分:3)
我重写了我的答案,因为我想创建一个完整的指南。
将GnuPG和MinGW-Get安装到没有空格的目录中。
用!!! GUI !!!安装MinGW后,打开mingw-get,安装这些组件:
mingw32-gcc(全部查看)
mingw32-libz(dll是最重要的)
Download并安装MSYS,这是一个用于运行make等命令的命令行工具包。
然后将c:\msys\1.0\bin\
(或安装它的任何位置)放在PATH变量的开头。重新启动eclipse或打开一个新的cmd,它应该可以工作。
在build.xml中: 第21行:
classpath="lib/junit-4.4.jar" added.(and the junit is in the lib dir)
在GNUmakefile中: 第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文件输出到build目录。我的工作目录是c:/ WORK / x,所以替换它不同的路径。不要在任何地方使用“程序文件”,因为你可以看到我必须从那里复制所有内容。
答案 1 :(得分:3)
错误消息告诉我<select ng-model="selectedValue" >
<option ng-repeat="deviceEach in devices" id="{{deviceEach.id}}">{{deviceEach.name}}</option>
</select>
找不到mingw32-gcc
。
您应首先安装mingw并将其添加到您的路径中。检查是否可以从命令行启动mingw32-gcc。
您是否正在运行cygwin的ant脚本?它引用/bin/sh
有点奇怪。也许你应该尝试从cygwin运行它。或者检查build.xml文件以查看如何调用mingw32-gcc。它必须是重新编译的代码目标。