GnuPG for Java ant library build error / error

I am GnuPG Java API for encrypting / decrypting files.
Googled and found the Java Wrapper GnuPG for Java , the GnuPG for Java wrapper for GPGME(GnuPG Made Easy,C language library) .
The official site also refers to this as a Java wrapper.
So, follow the instructions, configure ant and try running ant clean release
he throws mistakes. But maven build works and the jar file is also generated.
An error occurred while starting 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 

Refresh

I changed Java home to GNUmakefile , now it throws another error. It seems that c library not found, and this API was written for the Unix system, it seems after reading the error message. What C library is missing?

  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 

Can someone help me solve this problem? Where am I mistaken?

+7
java cryptography gnupg ant
source share
2 answers

I rewrote my answer because I wanted to create a complete guide.

Install GnuPG and MinGW-Get into the directory without spaces. After installing MinGW with !!! GUI !!!, open mingw-get, install these components:
mingw32-gcc (check all) mingw32-libz (dll is the most important)

Download and install MSYS , that is, a command line tool to run commands such as make.

Then put c:\msys\1.0\bin\ (or wherever you install it) at the beginning of the PATH variable. Restart eclipse or open a new cmd and it should work.

In the build.xml file: line 21:

 classpath="lib/junit-4.4.jar" added.(and the junit is in the lib dir) 

In the GNUmakefile: line 9:

 ALL_CFLAGS := -Wall -Wno-deprecated-declarations -fPIC 

line 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" 

line 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 

line 63:

 $(CC) $(DEBUG) $(ALL_CFLAGS) $(ALL_LDFLAGS) $^ -o "$(BUILD_DIR)/gnupg-for-java.dll" $(ALL_LIBS) 

Summary: This works for me and outputs the jar and dll file to the build directory. My working directory was c: / WORK / x, so replace the paths in which it differs. Do not use the "Program Files" anywhere, as you can see that I had to copy everything from there.

+3
source share

The error message says that it cannot find mingw32-gcc in /bin/sh .

You must install mingw first and add it to your path. Make sure mingw32-gcc can be run from the command line.

Are you using ant script from cygwin? It is a little strange that it refers to /bin/sh . Perhaps you should try running it from cygwin. Or check the build.xml file to find out how mingw32-gcc is called. This should be the goal of recompiling-c-code.

+3
source share

All Articles