permaculture playing cards
The moose likes Other JSE/JEE APIs and the fly likes Create DLL using JNI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Create DLL using JNI" Watch "Create DLL using JNI" New topic

Create DLL using JNI

Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

I am trying to use the Java Native Interface(JNI) to compile and run a simple program. I am following the steps found here:

I have gone through the first several steps successfully.

1) I created a Java program with appropriate native methods

2) I called javah -jni on my class file to create the C style header file

3) I wrote the implementation specified by the header in C++

4) Now I am at the step when I need to compile the C++ file and generate the .dll
I initially tried running this command:

but when I ran this I got an error:
C:\Program Files\Java\jdk1.7.0\include\jni.h(39) : fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory

So the command I am trying to run now is:

And When I run this I get:
LINK : fatal error LNK1104: cannot open file 'libcpmt.lib'
Which doesn't make any sense to me beucause 'libcpmt.lib' is on my PATH variable and should be including in the cl command because I point -I to the directory it is in.

Has anyone encountered this issue?
Any help would be great.

P.s - I have also posted this question on the Microsoft Visual C++ forum here:

"If the facts don't fit the theory, get new facts" --Albert Einstein
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Someone answered my question on the MSDN site. The problem was before I could compile the DLL I needed to run

Which is located in the C:\Program Files\Microsoft Visual Studio 9.0\VC\bin folder

I agree. Here's the link:
subject: Create DLL using JNI
It's not a secret anymore!