GnuPG for Java library ant build issue/bug - java

I'm working GnuPG Java API to encrypt/decrypt files.
Googled and found a Java Wrapper GnuPG for Java, Java wrapper for GPGME(GnuPG Made Easy,C language library).
Official website also referring this as the Java wrapper.
So followed the instructions, set up ant and tried to run ant clean release
it is throwing errors.
But maven build working and jar file also generated.
Following error occured while running 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
Update
I changed the Java home in GNUmakefile, Now it is throwing different error. Seems c library not found and this API is written for Unix system seems by reading the error message. What C library 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 anyone help me to solve this issue ?
Where I'm making mistake ?

I rewrote my answer because I wanted to create a complete guide.
Install GnuPG and MinGW-Get to a directory without spaces.
After you installed MinGW with !!!GUI!!!, open mingw-get, install these components:
mingw32-gcc (check all)
mingw32-libz (the dll is the most important)
Download and install MSYS, that is a command line toolkit for running commands like make.
Then put c:\msys\1.0\bin\ (or wherever you installed it) on the beginning of the PATH variable. Restart eclipse or open a new cmd, and it should work.
In the build.xml:
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 is working for me and outputs the jar and dll file to the build directory. My work directory was c:/WORK/x so replace the paths where it is different. Don't use "Program Files" anywhere, as you can see I had to copy everything from there.

The error message is telling that it cannot find mingw32-gcc in /bin/sh.
You should install mingw at first and add it to your path. Check that mingw32-gcc can be launched from the command line.
Are you running the ant script from cygwin? It's a bit strange that it is referring /bin/sh. Maybe you should try to run it from cygwin. Or check the build.xml file to see how mingw32-gcc is called. It must be recompile-c-code target.

Related

build error icedtea7-native using meta-java layer

I am getting a build error for icedtea7-native
make[6]: *** [../../../common/Library.gmk:225: /home/amodster/Yocto/poky-rpi3/build/tmp/work/x86_64-linux/icedtea7-native/2.1.3-r1.0/icedtea-2.1.3/build/openjdk.build-boot/lib/amd64/libj2pcsc.so] Error 1
make[6]: Leaving directory '/home/amodster/Yocto/poky-rpi3/build/tmp/work/x86_64-linux/icedtea7-native/2.1.3-r1.0/icedtea-2.1.3/build/openjdk-boot/jdk/make/sun/security/smartcardio'
More info when running make from command line
~/Yocto/poky-rpi3/build/tmp/work/x86_64-linux/icedtea7-native/2.1.3-r1.0/icedtea-2.1.3/build/openjdk-boot/jdk/make/sun/security/smartcardio$ make
Java sources to be compiled: (listed in file ../../../../build/linux-amd64/tmp/sun/sun.security.smartcardio/j2pcsc/.classes.list)
../../../../src/share/classes/sun/security/smartcardio/CardImpl.java
../../../../src/share/classes/sun/security/smartcardio/ChannelImpl.java
../../../../src/share/classes/sun/security/smartcardio/PCSCException.java
../../../../src/share/classes/sun/security/smartcardio/PCSC.java
../../../../src/share/classes/sun/security/smartcardio/PCSCTerminals.java
../../../../src/share/classes/sun/security/smartcardio/SunPCSC.java
../../../../src/share/classes/sun/security/smartcardio/TerminalImpl.java
../../../../src/solaris/classes/sun/security/smartcardio/PlatformPCSC.java
Running javac:
-sourcepath ../../../../build/linux-amd64/gensrc:../../../../src/solaris/classes:../../../../src/share/classes -bootclasspath ../../../../build/linux-amd64/classes: -d ../../../../build/linux-amd64/classes #../../../../build/linux-amd64/tmp/sun/sun.security.smartcardio/j2pcsc/.classes.list
/bin/sh: 7: -sourcepath: not found
make: *** [../../../../make/common/Rules.gmk:236: .compile.classlist] Error 127
I am checking if these exist
-sourcepath ../../../../build/linux-amd64/gensrc:../../../../src/solaris/classes:../../../../src/share/classes
ls ../../../../build/linux-amd64/gensrc ---this is not there---
ls ../../../../src/solaris/classes
ls ../../../../src/share/classes
Host: Ubuntu 22.04
Target: RPi3B+
Build System: Yocto / bitbake
First tried: bitbake icedtea7-native
Second tried: ~/Yocto/poky-rpi3/build/tmp/work/x86_64-linux/icedtea7-native/2.1.3-r1.0/icedtea-2.1.3/build/openjdk-boot/jdk/make/sun/security/smartcardio$ make

rJava: non-zero exit status

I have been trying to install rJava using the following commands:
install.packages('rJava',,'http://www.rforge.net/')
or
install.packages('rJava', type = 'source', INSTALL_opts='--merge-multiarch')
but each time I fail due to this error:
WARNING: JRI could NOT be built Set IGNORE=1 if you want to build
rJava anyway. ERROR: configuration failed for package 'rJava'. I have uninstalled and re-installed both version of java on my machine but still no help!
Does anyone has a solution ?
the full description is as below:
install for i386
installing source package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked Generate Windows-specific files (src/jvm-w32) ... make: Entering directory
'/Users/ahkay/AppData/Local/Temp/RtmpKalUob/R.INSTALL192609e43b16/rJava/src/jvm-w32'
C:/Rtools/mingw_32/bin/dlltool --as C:/Rtools/mingw_32/bin/as
--input-def jvm.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a C:/Rtools/mingw_32/bin/gcc -O2 -c -o findjava.o
findjava.c C:/Rtools/mingw_32/bin/gcc -s -o findjava.exe findjava.o
make: Leaving directory
'/Users/ahkay/AppData/Local/Temp/RtmpKalUob/R.INSTALL192609e43b16/rJava/src/jvm-w32'
Find Java... ./configure.win: line 15: [: too many arguments
JAVA_HOME=C:/Program Files/Java/jre1.8.0_202
=== Building JRI === configure.win: line 21: [: too many arguments JAVA_HOME=C:/Program Files/Java/jre1.8.0_202
R_HOME=C:/PROGRA~1/R/R-35~1.2 Creating Makefiles ... Configuration
done. make -C src JRI.jar make[1]: Entering directory
'/Users/ahkay/AppData/Local/Temp/RtmpKalUob/R.INSTALL192609e43b16/rJava/jri/src'
C:/Program Files/Java/jre1.8.0_202/bin/javac -d . ../RList.java
../RBool.java ../RVector.java ../RMainLoopCallbacks.java
../RConsoleOutputStream.java ../Mutex.java ../Rengine.java
../REXP.java ../RFactor.java ../package-info.java make[1]: C:/Program:
Command not found make[1]: * [Makefile.all:41:
org/rosuda/JRI/Rengine.class] Error 127 make[1]: Leaving directory
'/Users/ahkay/AppData/Local/Temp/RtmpKalUob/R.INSTALL192609e43b16/rJava/jri/src'
make: * [Makefile.all:19: src/JRI.jar] Error 2
**** WARNING: JRI could NOT be built Set IGNORE=1 if you want to build rJava anyway. ERROR: configuration failed for package 'rJava'
removing 'C:/Users/ahkay/Documents/R/win-library/3.5/rJava' In R CMD INSTALL In R CMD INSTALL Warning in install.packages : installation
of package ‘rJava’ had non-zero exit status
I have experienced same issue and following approach worked for me in my Mac OS 10.13.6, you can apply minor OS related changes if using in other OS.
OS:
Installing rJava Manually
# curl -#ROL https://www.rforge.net/rJava/snapshot/rJava_0.9-8.tar.gz
# R CMD INSTALL rJava_0.9-8.tar.gz
# su -
Location you have installed R software, you might have different location.
# cd /Library/Frameworks/R.framework/Versions/3.5/Resources/lib
I found that different Java used by R, and forcing by softlink:
#ln -s /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/lib/server/libjvm.dylib libjvm.dylib
Remember, you need to put your JAVA_HOME in the following location in R Studio:
>Sys.setenv(JAVA_HOME = "/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home")
Verifying rJava working in R Studio:
>require(rJava)

Error building jpy `gcc: error: : No such file or directory`

I am trying to build jpy for using the SNAP API of the european space agency in my ubuntu 16.04 with anaconda. After setting all my java, jdk and jvm paths correctly, I executed
python setup.py build
and got the following error:
src/main/c/jni/org_jpy_PyLib.c:254:26: warning: unused variable ‘state’ [-Wunused-variable]
PyGILState_STATE state = PyGILState_Ensure();
^~~~~ gcc -pthread -shared -B /home/delgado/local/anaconda3/compiler_compat
-L/home/delgado/local/anaconda3/lib -Wl,-rpath=/home/delgado/local/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/src/main/c/jpy_module.o build/temp.linux-x86_64-3.6/src/main/c/jpy_diag.o build/temp.linux-x86_64-3.6/src/main/c/jpy_conv.o build/temp.linux-x86_64-3.6/src/main/c/jpy_compat.o build/temp.linux-x86_64-3.6/src/main/c/jpy_jtype.o build/temp.linux-x86_64-3.6/src/main/c/jpy_jarray.o build/temp.linux-x86_64-3.6/src/main/c/jpy_jobj.o build/temp.linux-x86_64-3.6/src/main/c/jpy_jmethod.o build/temp.linux-x86_64-3.6/src/main/c/jpy_jfield.o build/temp.linux-x86_64-3.6/src/main/c/jni/org_jpy_PyLib.o -L
-L/home/delgado/local/anaconda3/lib -ljvm -ldl -lpython3.6m -o build/lib.linux-x86_64-3.6/jpy.cpython-36m-x86_64-linux-gnu.so
-Xlinker -rpath gcc: error: : No such file or directory error: command 'gcc' failed with exit status 1
I do not know precisely which file is missing and why it is missing.
Using a built version of jpy in conda solved the issue. I suggest eg: conda install -c terradue jpy
hope this still helps somebody

Autoreconf failing when installing (py)COMPSs in a clusters

I tried to install pyCOMPSs (v1.4) on a Cluster system using the
installation script for Supercomputers.
The script terminates with the following error:
libtool: link: ranlib .libs/libcbindings.a
libtool: link: ( cd ".libs" && rm -f "libcbindings.la" && ln -s
"../libcbindings.la" "libcbindings.la" )
make[1]: Entering directory
`/home/xxx/repos/pycompss/COMPSs/Bindings/c/src/bindinglib'
/usr/bin/mkdir -p
'/home/cramonco/svn/compss/framework/trunk/builders/specs/deb/compss-c-binding/tmp/opt/COMPSs/Bindings/c/lib'
/usr/bin/mkdir: cannot create directory ‘/home/cramonco’: Permission denied
make[1]: *** [install-libLTLIBRARIES] Error 1
make[1]: Leaving directory
`/home/xxx/xxx/repos/pycompss/COMPSs/Bindings/c/src/bindinglib'
make: *** [install-am] Error 2
BindingLib Installation failed, please check errors above!
Seems the error is due to the package includes a previous configuration
and in your case the autoreconf is not overwritting the Makefile and
other files produced by autotools. try with
running
cd /home/xxx/repos/pycompss/COMPSs/Bindings/c/src/bindinglib
make maintainer-clean
After this run again the install command

fatal error: jni.h: No such file or directory Netbeans IDE

I want to learn that how we can call a java function from C++,after following some links i came to know that we need to add following header file in C++ file
#include <jni.h>
but when I added this file in C++ file in Netbeans IDE I got following error
fatal error: jni.h: No such file or directory
How can this error be removed, I am just beginner in JNI.
I went through previous questions asked at stackoverflow but was not able to go through the Problem.
Here is my comile output:
"/C/MinGW/MSYS/1.0/bin./make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
"/C/MinGW/MSYS/1.0/bin./make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/jnidemo.exe
make.exe[2]: Entering directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp:9:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
make.exe[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make.exe[2]: Leaving directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
You are compiling with MinGW without including Java headers, thats why it complains about not found
Try to add this option to your compilation command -I"c:/path/to/jdk/include" -I"c:/path/to/jdk/include/win32" -D__int64="long long".
The last option is to avoid the error caused because windows compiler uses the type __int64 and gcc uses long long.
Have you looked at the Netbeans JNI tutorial?
It goes through everything you should need to do in pretty good detail.

Categories

Resources