1
votes

I am trying to use JNI to integrate a .C code with my Java project.

While trying to generate the .dll file using vcvars32.bat in visual studio 2017 it gives me an error message tells:

"C:\Program Files\Java\jdk1.8.0_151\include\jni.h(39): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory"

I removed the including of stdio.h library in my C code but it didn't help.

My command is:

"cl -I"C:\Program Files\Java\jdk1.8.0_151\include" -I"C:\Program Files\Java\jdk1.8.0_151\include\win32" -LD "Factorial.c" -Fe"Factorial.dll""

1
Are you sure that you jvm is 32bit ? In 2018 it sounds strange, i.e. in most cases you need vcvars64.batVictor Gubin
I tried vcvars64.bat, vcvarsall.bat and even VsDevCmd.bat too but unfortunately it didn't help tooAhmed Salah
Ok, let's make some simple nmake file and check:Victor Gubin
make a file like link: compile ln /DLL /LTCG /LIBPATH:"C:\Program Files\Java\jdk1.8.0_151\lib" OUT:factorial.dll msvcrt.lib kernel32.lib jvm.lib Factorial.obj compile: cl /c /nologo /GL /Zl Factorial.c /FoFactorial.obj and Use nmake to build it. The Nmake manuals docs.microsoft.com/en-us/cpp/build/nmake-reference engr.iupui.edu/~dskim/downloadable/reference_Nmake.pdfVictor Gubin
I removed the including of stdio.h library in my C code but it didn't help. You're not going to be able to compile 32- or 64-bit without the standard C headers. Something is likely wrong with your Visual Studio install. What's the full path to the vcvars32.bat file that you used to set up your environment? Can you try another one? Can you compile a simple "Hello World!" C program in the Visual Studio GUI that has #include <stdio.h> in it?Andrew Henle

1 Answers

1
votes

After sometime of searching and failing I had to generate it by VS13 vsvars32.bat note that vsvars not VS17's vcvars that generated 32-bit dll and because my platform is 64-bit I had to install and switch to 32-bit JVM and problem is resolved.