Board index » jbuilder » Problem compiling a C++ dll using JNI

Problem compiling a C++ dll using JNI


2003-08-14 11:15:00 PM
jbuilder22
I've read the tutorial on JNI on the sun web site, read some newsgroup about
JNI and i still can't find a way to compile my C++ dll using JNI.h
I'm actually trying to get the Java "HelloWorld" tutorial to work
here is my files
HelloWorldImp.c
----------------
#include "jni.h"
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
HelloWorld.h (Generated by javah.exe)
---------------
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: displayHelloWorld
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
I tried to compile that in VC++ 6
I'm getting this error :
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinSize/test3.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I also tried to compile using a third party C compiler (lcc-win32)
And I'm getting this error :
main.obj .text: undefined reference to '_WinMain@16'
Specified export _JNI_OnLoad@8 is not defined
Specified export _JNI_OnUnload@8 is not defined
Missing exports. Aborting
linker returned 1
Any help would be appreciated
Also if anyone have working source of a C++ dll using jni i would appreciate
to get a look at it thanks for your help
Sam
 
 

Re:Problem compiling a C++ dll using JNI

"Sam" < XXXX@XXXXX.COM >writes:
Quote
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinSize/test3.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Don't compile to an EXE but to a DLL. Check your project's settings:
This error means it tried to link up an EXE.