I'm trying to create a DLL:
--------------/HelloWorld.cpp/------
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayMessage(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
-----------------//-------------------
But I do not have any idea in order to compile this CPP with g++. Wich is the way?
(I've got already created the Java classes and the C++ header file)
Thank you very much.
Your example is C, not C++, so why not use gcc instead of g++?
At any rate, did you look at the dll documentation and examples on the
cygwin site?
http://cygwin.com/docs.html
http://cygwin.com/faq/faq_4.html#SEC107
http://cygwin.com/faq/faq_4.html#SEC109
/gordon
--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m
As Gordon said, use GCC. A typical command might look like this:
gcc -shared -o hello.dll (path to JNI headers) HelloWorld.cpp -Wl,--kill-at
The item (path to JNI headers) is something like
-ID:/j2sdk1.4.0/include -ID:/j2sdk1.4.0/include/win32
I do really want to use C++, not C. I know that the sent code is C,
but it was due to the test I was making.
I'm trying with:
#include <iostream.h>
#include "HelloWorld.h" // this header file was generated by javah
using namespace std;
JNIEXPORT void JNICALL Java_HelloWorld_displayMessage(JNIEnv *env,
jobject obj)
{
cout << "Hello World! ";
}
I tried with:
c:> g++ -I"D:\j2sdk\include" -I"D:\j2sdk\include\win32" HelloWorld.cpp
-shared -o HelloWorldImp.dll
But I get this error message when calling from 'Main.java':
Exception in thread "main" java.lang.UnsatisfiedLinkError:
displayMessage
at HelloWorld.displayMessage(Native Method)
at Main.main(Main.java:6)
Thank you.
Gordon Beaton <n...@for.email> wrote in message news:<a90voi$or9$1...@news.du.uab.ericsson.se>...
I have already answered this in comp.lang.java.programmer. Please
don't post the same questions to multiple newsgroups.