Toon posts:

[VC++] Shared Library aanmaken *

Pagina: 1
Acties:
  • 39 views sinds 30-01-2008

Verwijderd

Topicstarter
Hallo,

Ben nu beetje bezig met Java Native Interface. Ik heb een tutorial gevonden om de basis van deze opties te kunnen leren:
http://java.sun.com/docs/books/tutorial/native1.1/

Alleen loop ik vast bij het aanmaken van een .dll in windows. Ze zeggen dat ik de volgende code moet gebruiken in Microsoft Visual C++ studio.
--

On Microsoft Windows, the following command builds a dynamic link library hello.dll using Microsoft Visual C++ 4.0:

cl -Ic:\java\include -Ic:\java\include\win32
-LD HelloWorldImp.c -Fehello.dll

Of course, you need to specify the include path that corresponds to the setup on your own machine.

--

Kan ik deze library ook op een andere manier aanmaken? Met een command line ofzo? Of met Bloodshed Dev-C++? Zo ja, hoe dan?

Alvast tnx

Rappas

  • .oisyn
  • Registratie: September 2000
  • Laatst online: 04:06

.oisyn

Moderator Devschuur®

Demotivational Speaker

Ja natuurlijk kan dat

In de JNI specs staat toch wel tegen welke libraries je moet linken, en welke includes je moet gebruiken? 'T is gewoon een kwestie van de juiste informatie invullen bij je project properties in Dev-C++

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.


Verwijderd

Topicstarter
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
----
/* 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
----

En de class file van HelloWorld.java
----
class HelloWorld {
public native void displayHelloWorld();

static {
System.loadLibrary("hello");
}

public static void main(String[] args) {
new HelloWorld().displayHelloWorld();
}
}
----

En dit dan
----
On Microsoft Windows, the following command builds a dynamic link library hello.dll using Microsoft Visual C++ 4.0:

cl -Ic:\java\include -Ic:\java\include\win32
-LD HelloWorldImp.c -Fehello.dll
----

Wat ik nu dan bij de properties van Dev-C++ in moet voeren???
Geen idee.
Maar anders probeer ik het wel ergens anders met Visual

Verwijderd

Topicstarter
de jni.h en de stdio.h file heb ik niet???

Verwijderd

Topicstarter
Ik bedoel alleen de jni.h ontbreekt in de includes van Dev.

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 01:56
Misschien even je include directories goed zetten? Of anders zelfs de JNI SDK installeren, maar als je die niet hebt is het me een raadsel hoe je ueberhaupt je stub headers hebt weten te genereren.

edit:
Oh ja, code tussen code tags, graag (zoals in de FAQ staat beschreven). Verder zijn we op dit moment niet heel erg geïnteresseerd in je broncode. ;)

[ Voor 30% gewijzigd door Soultaker op 01-10-2003 16:03 ]


  • .oisyn
  • Registratie: September 2000
  • Laatst online: 04:06

.oisyn

Moderator Devschuur®

Demotivational Speaker

Mja, om software te configgen gaan wij je niet helpen. We mogen toch wel enigzins verwachten dat onze bezoekers weten hoe ze include directories kunnen instellen bij hun IDE. Als ze dat niet weten dan moeten ze de manual van hun IDE maar even doorlezen, daar staat het vast wel in beschreven :)

verder: P&W FAQ - De "quickstart"

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.

Pagina: 1

Dit topic is gesloten.