|
Re: CDT building DLL for JNI with MinGW [message #160363 is a reply to message #160347] |
Tue, 13 December 2005 13:31 |
Eclipse User |
|
|
|
Originally posted by: jay.planettools.com
> So far, it looks as though Java is loading the DLL alright, however I am
> unable to link to any of the specified JNI entry points.
> I am pretty sure I have all the naming conventions satisfied, and I am using
> function prototypes as generated by javah.
> MinGW has its own versions of headers and libraries for Windows system
> functions. Is there any incompatibility with what Java expects in a JNI
> application DLL? Has anyone else made a JNI dll using MinGW?
Mike,
We are using the CDT and MinGW to compile and run DLL's currently. It
works fine, although required a significant amount of tweeking. As you
point out the naming conventions are tricky. Maybe you could send some
code snippets from the C side and the Java side on how they are called and
calling.
I am presently attempting to setup our DLL code to run as a stand-alone
exe (as you are already doing) and am having significant trouble with
that. It would seem that I need to get the jvm.lib to link in to the
project but I cannot figure out how to do that. I always tells me that it
cannot find the file. The help documentation is no help as it appears to
reference a completely different interface (one with a "External Library"
function). Although when I look at the linker command in the console it
appears correct, the "L" points to the directory and the "-l" option
points to the library. If you have any pointers for me on the method for
including the library so I can get access to the Java functions I would
certainly appreciate it.
Thanks,
Jay
|
|
|
Re: CDT building DLL for JNI with MinGW [message #160379 is a reply to message #160363] |
Tue, 13 December 2005 19:58 |
Mike Greenawalt Messages: 50 Registered: July 2009 |
Member |
|
|
I wonder what "tweeking" you had to do?
Your situation sounds different from mine. I am not trying to call Java
methods from C++, and I do not need the jvm.lib at all. My dll is actually
relatively simple -- it creates an invisible window and a message-handling
thread, and then simply marshals message strings between a Java application,
and a separate Windows application on the other side. I just have to get
strings out of the calling JVM and look up a methodId for a callback.
A colleague built my dll using M$ tools, and it worked without change. The
dll loads, and I can call the JNI methods in it. That means I had the naming
rigamarole right.
I wish I could be of more help.
-- Mike
"Jay Nance" <jay@planettools.com> wrote in message
news:2ad328921531095ba5950801d61f4cae$1@eclipse.org...
>> So far, it looks as though Java is loading the DLL alright, however I am
>> unable to link to any of the specified JNI entry points.
>
>> I am pretty sure I have all the naming conventions satisfied, and I am
>> using function prototypes as generated by javah.
>
>> MinGW has its own versions of headers and libraries for Windows system
>> functions. Is there any incompatibility with what Java expects in a JNI
>> application DLL? Has anyone else made a JNI dll using MinGW?
>
> Mike,
>
> We are using the CDT and MinGW to compile and run DLL's currently. It
> works fine, although required a significant amount of tweeking. As you
> point out the naming conventions are tricky. Maybe you could send some
> code snippets from the C side and the Java side on how they are called and
> calling.
>
> I am presently attempting to setup our DLL code to run as a stand-alone
> exe (as you are already doing) and am having significant trouble with
> that. It would seem that I need to get the jvm.lib to link in to the
> project but I cannot figure out how to do that. I always tells me that it
> cannot find the file. The help documentation is no help as it appears to
> reference a completely different interface (one with a "External Library"
> function). Although when I look at the linker command in the console it
> appears correct, the "L" points to the directory and the "-l" option
> points to the library. If you have any pointers for me on the method for
> including the library so I can get access to the Java functions I would
> certainly appreciate it.
>
> Thanks,
>
> Jay
>
>
>
|
|
|
Re: CDT building DLL for JNI with MinGW [message #160511 is a reply to message #160363] |
Thu, 15 December 2005 06:04 |
Eclipse User |
|
|
|
Originally posted by: divis1969.mail.ru
Jay,
Dis you use exactly "jvm.lib" for the linker -j option?
If so, I think you could test the following: rename jvm.lib into libjvm.a
and use "jvm" for -l option (i.e. command line should look like
"gcc -L<your_dir> -ljvm .. ")
Probably it will cause some errors caused by unknown library format (since
it obviously was compiled by another compiler) but at least you will be sure
that linker has found this library. :-)
Dmitry
"Jay Nance" <jay@planettools.com> wrote in message
news:2ad328921531095ba5950801d61f4cae$1@eclipse.org...
>> So far, it looks as though Java is loading the DLL alright, however I am
>> unable to link to any of the specified JNI entry points.
>
>> I am pretty sure I have all the naming conventions satisfied, and I am
>> using function prototypes as generated by javah.
>
>> MinGW has its own versions of headers and libraries for Windows system
>> functions. Is there any incompatibility with what Java expects in a JNI
>> application DLL? Has anyone else made a JNI dll using MinGW?
>
> Mike,
>
> We are using the CDT and MinGW to compile and run DLL's currently. It
> works fine, although required a significant amount of tweeking. As you
> point out the naming conventions are tricky. Maybe you could send some
> code snippets from the C side and the Java side on how they are called and
> calling.
>
> I am presently attempting to setup our DLL code to run as a stand-alone
> exe (as you are already doing) and am having significant trouble with
> that. It would seem that I need to get the jvm.lib to link in to the
> project but I cannot figure out how to do that. I always tells me that it
> cannot find the file. The help documentation is no help as it appears to
> reference a completely different interface (one with a "External Library"
> function). Although when I look at the linker command in the console it
> appears correct, the "L" points to the directory and the "-l" option
> points to the library. If you have any pointers for me on the method for
> including the library so I can get access to the Java functions I would
> certainly appreciate it.
>
> Thanks,
>
> Jay
>
>
>
|
|
|
Re: CDT building DLL for JNI with MinGW [message #196211 is a reply to message #160379] |
Tue, 10 July 2007 22:41 |
Cameron Taggart Messages: 28 Registered: July 2009 |
Junior Member |
|
|
I'm hoping to resurrect this thread from a while back. I'm using
Eclipse Europa with MinGW and I'm trying to build a ddl with JNI
methods. I have a trivial C function (from project GlueGen's example #1):
function.h
int one_plus(int a);
function.c
int one_plus(int a) {
return 1 + a;
}
I was able to compile the above into a dll with the native JNI code.
When I try to load and use the dll from Java, I get this error:
java.lang.UnsatisfiedLinkError: testfunction.TestFunction.one_plus(I)I
My guess is that it has something to do with how I built the dll, and
here is the MinGW FAQ entry regarding JNI:
http://www.mingw.org/mingwfaq.shtml#faq-jni-dll
I'm not sure how that translates into CDT managed build settings. I'm
guessing that I need to change stuff in MinGW C Linker > Shared Library
Settings.
Any ideas???
cheers,
Cameron
Mike Greenawalt wrote:
> I wonder what "tweeking" you had to do?
>
> Your situation sounds different from mine. I am not trying to call Java
> methods from C++, and I do not need the jvm.lib at all. My dll is actually
> relatively simple -- it creates an invisible window and a message-handling
> thread, and then simply marshals message strings between a Java application,
> and a separate Windows application on the other side. I just have to get
> strings out of the calling JVM and look up a methodId for a callback.
>
> A colleague built my dll using M$ tools, and it worked without change. The
> dll loads, and I can call the JNI methods in it. That means I had the naming
> rigamarole right.
>
> I wish I could be of more help.
>
> -- Mike
>
> "Jay Nance" <jay@planettools.com> wrote in message
> news:2ad328921531095ba5950801d61f4cae$1@eclipse.org...
>>> So far, it looks as though Java is loading the DLL alright, however I am
>>> unable to link to any of the specified JNI entry points.
>>> I am pretty sure I have all the naming conventions satisfied, and I am
>>> using function prototypes as generated by javah.
>>> MinGW has its own versions of headers and libraries for Windows system
>>> functions. Is there any incompatibility with what Java expects in a JNI
>>> application DLL? Has anyone else made a JNI dll using MinGW?
>> Mike,
>>
>> We are using the CDT and MinGW to compile and run DLL's currently. It
>> works fine, although required a significant amount of tweeking. As you
>> point out the naming conventions are tricky. Maybe you could send some
>> code snippets from the C side and the Java side on how they are called and
>> calling.
>>
>> I am presently attempting to setup our DLL code to run as a stand-alone
>> exe (as you are already doing) and am having significant trouble with
>> that. It would seem that I need to get the jvm.lib to link in to the
>> project but I cannot figure out how to do that. I always tells me that it
>> cannot find the file. The help documentation is no help as it appears to
>> reference a completely different interface (one with a "External Library"
>> function). Although when I look at the linker command in the console it
>> appears correct, the "L" points to the directory and the "-l" option
>> points to the library. If you have any pointers for me on the method for
>> including the library so I can get access to the Java functions I would
>> certainly appreciate it.
>>
>> Thanks,
>>
>> Jay
>>
>>
>>
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 5.04739 seconds