I'm trying to compile a 27KB .c file in Powershell (Windows 10) using java and the TDM-GCC MinGW provided on sourceforge (https://sourceforge.net/projects/tdm-gcc/). The code I am using (from published paper http://journals.plos.org/ploscompbiol/article?id=10.1371%2Fjournal.pcbi.1001059) generates an executable file using the following code:
gcc -O3 -finline-functions -fomit-frame-pointer -DNDEBUG -fno-strict-aliasing --param max-inline-insns-single=1800 -std=c99 -msse2 -DHAVE_SSE2 -DDSFMT_MEXP=521 -o toy_bat toy_bat.c
When I compile a 6KB example file this works fine. However when I compile the 27KB file I get the following error:
C:/TDM-GCC-64/bin/.../lib/crt2.o: In function '__tmainCRTStartup' followed by a load of 'relocation truncated to fit' messages.
From what I've read onling this error normally comes from a file being too large, but I find it hard to believe that A 27KB file is causing this. Does anyone have any suggestions as to what may be causing this?
Thanks!
Related
I'm trying to cross-compile the JNI Bridge Jlibfprint using buildroot.
This is the source code.
Here is the .mk file:
JLIBFPRINT_VERSION = 775295f08174d11d39da9e327120b128ef270fc4
JLIBFPRINT_SITE = $(call github,eduardobogoni,jlibfprint,$(JLIBFPRINT_VERSION))
JLIBFPRINT_AUTORECONF = YES
JLIBFPRINT_SUBDIR = JlibFprint_jni
#JLIBFPRINT_CONF_OPTS = --enable-debug-log --enable-udev-rules=no --disable-debug-log
JLIBFPRINT_INSTALL_STAGING = YES
define PREPARE_FILES_AND_FIX_DIRECTORY
cd $(#D)/JlibFprint_jni && \
libtoolize
endef
JLIBFPRINT_PRE_CONFIGURE_HOOKS += PREPARE_FILES_AND_FIX_DIRECTORY
$(eval $(autotools-package))
Extract, Patch, Update, Configure, Autoreconfiguring, Patching libtool run without problem.
Then it failed at Building stage with this:
libfprint_jni_la-jlibfprint_JlibFprint.o
In file included from jlibfprint_Device.cpp:1:0:
jlibfprint_Device.h:5:10: fatal error: jni.h: No such file or directory
#include <jni.h>
^~~~~~~
compilation terminated.
Then I added, these includes to the /JlibFprint_jni/src/Makefile.am
ADD_INCLUDES=-I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/mariano/buildroot/output/build/libfprint-0.7.0 -I/home/mariano/buildroot/output/build/libfprint-0.7.0/libfprint/nbis/include
And now it fails with:
arm-linux-gnueabihf-g++: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/lib/jvm/java-11-openjdk-amd64/include'
arm-linux-gnueabihf-g++: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/lib/jvm/java-11-openjdk-amd64/include'
libtool: compile: /home/mariano/buildroot/output/host/bin/arm-linux-gnueabihf-g++ -DPACKAGE_NAME=\"libfprint_jni\" -DPACKAGE_TARNAME=\"libfprint_jni\" -DPACKAGE_VERSION=\"1.0\" "-DPACKAGE_STRING=\"libfprint_jni 1.0\"" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libfprint_jni\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING=1 -DHAVE_IOSTREAM=1 -DHAVE_LIBFPRINT_FPRINT_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/mariano/buildroot/output/build/libfprint-0.7.0 -I/home/mariano/buildroot/output/build/libfprint-0.7.0/libfprint/nbis/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -c jlibfprint_JlibFprint.cpp -fPIC -DPIC -o .libs/libfprint_jni_la-jlibfprint_JlibFprint.o
Makefile:496: recipe for target 'libfprint_jni_la-jlibfprint_Device.lo' failed
Jlibfprint requires a JDK, but Buildroot doesn't have a JDK package. Therefore, building Jlibfprint using Buildroot will never work.
I downloaded JDK for ARM 32 bits and addded the includes into that folder.
I removed the BR2_COMPILER_PARANOID_UNSAFE_PATH=n as Arnout said it was wrong. And it cross-compiled without issues.
I ran the Sample Run and it worked with an Upek fingerprint scanner.
I am working on this now. Buildroot includes openjdk, but does not install the jni header files, so when using staging as sysroot for cross compilation, things go wrong.
As far as I can tell the jni headers (jni.h and jni_md.h) serve as type translations only and can be included without problem for the target. I added them to the sysroot and compiling works without issues.
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
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.
I am trying to use JNI to call a Java program from a C++ program. A supplier has put in place some phone apparatus and it only uses C++. I want to write a Screen Popper but don't want to do it in C++ so therefore want to pass across the event of the phone call coming in and the number to a Java routine to handle. I am using Netbeans as it makes the coding easier (usually!). I have not done C++ before which is why I want to escape to Java ASAP!
I am following instructions here: http://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html
Which seem to set out how to call a Java routine from C++ but I cannot get it to compile. I have got as far as I with lots of help from this site but now I'm stumped.
I have added the '-D__int64=long long' switch to the compiler options for the project and added the Java libraries to the Application include paths. I have reparsed the code using code assistance. But now I'm left with this error:
make[1]: Entering directory '/cygdrive/f/Javadev/Sample2'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/sample2.exe
make[2]: Entering directory '/cygdrive/f/Javadev/Sample2'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f build/Debug/Cygwin_4.x-Windows/main.o.d
g++.exe -D__int64=long long -c -g -I/cygdrive/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_33/include/win32 -I/cygdrive/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_33/include -MMD -MP -MF build/Debug/Cygwin_4.x-Windows/main.o.d -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
nbproject/Makefile-Debug.mk:65: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' failed
make[2]: Leaving directory '/cygdrive/f/Javadev/Sample2'
nbproject/Makefile-Debug.mk:58: recipe for target '.build-conf' failed
make[1]: Leaving directory '/cygdrive/f/Javadev/Sample2'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
g++: error: long: No such file or directory
make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
All source files are under F:\javadev, Sample2 is C++ and Sample3 is Java. Is there something else I need to include from Cygwin? It seems to say there is a problem with 'long' but that only really occurs in the switch and without it it fails even more catastrophically, saying that __int64 does not have a type.
I'm trying to implement the JavaFuse project but when I execute the make command I'm getting this error:
gcc -shared build/contextClass.o build/conninfoClass.o build/javafuse_jni.o build/statvfsClass.o build/fsClass.o build/utimebufClass.o build/fileinfoClass.o build/statClass.o -o build/libjavafuse.so
Error:
build/contextClass.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: * [libjavafuse.so] Error 1
I'm using Ubuntu.
Could anyone please suggest what is the problem?
I recommend fuse-jna, it's a project that I've used and it doesn't need to be compiled and also, it's alive and you may find it here fuse-jna. hope it'll help you