delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/18/12:51:01

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: Tucker Maney <maney AT aic DOT nrl DOT navy DOT mil>
Date: Fri, 18 May 2001 12:50:35 -0400 (EDT)
Message-Id: <200105181650.MAA00975@sun31.aic.nrl.navy.mil>
To: cygwin AT sources DOT redhat DOT com
Subject: java and C++
Mime-Version: 1.0

--2f1e_5ed6-3f11_2f5-5656_5acc
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-MD5: vnPb7ITKWK0qYfVetT59Fg==
X-Sun-Data-Type: text

I would like to be able to run C code from Java.  I've done this under
Solaris with no problems, but now I'm using cygwin gcc under Windows 2000.
I thought i'd start with the simple example on the Java Sun webpage.
Get stuck making the dll.  Mail errors have to do with jlong in the jni.h
file.  Have put copies of all files, etc, in attachment.

Any help would be greatly appreciated.  tucker
--2f1e_5ed6-3f11_2f5-5656_5acc
Content-Type: text/plain; charset=us-ascii; name=HelloWorld.txt
Content-Transfer-Encoding: quoted-printable
Content-MD5: N8ySzJwqdA7qOY4tljOv8g==
Content-Description: HelloWorld.txt
Content-Disposition: attachment; filename=HelloWorld.txt
X-Sun-Data-Type: text

// HelloWorld.java  --compiles into HelloWorld.class=0D
=0D
class HelloWorld {=0D
    public native void displayHelloWorld();=0D
=0D
    static {=0D
        System.loadLibrary("hello");=0D
    }=0D
    =0D
    public static void main(String[] args) {=0D
        new HelloWorld().displayHelloWorld();=0D
    }=0D
}=0D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=0D
// HelloWorld.h=0D
=0D
/* DO NOT EDIT THIS FILE - it is machine generated */=0D
#include <jni.h>=0D=0D
/* Header for class HelloWorld */=0D
=0D
#ifndef _Included_HelloWorld=0D
#define _Included_HelloWorld=0D=0D
#ifdef __cplusplus=0D
extern "C" {=0D
#endif=0D=0D
/*=0D=0D
 * Class:     HelloWorld=0D=0D
 * Method:    displayHelloWorld=0D=0D
 * Signature: ()V=0D=0D
 */=0D=0D
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld=0D=0D
  (JNIEnv *, jobject);=0D
=0D=0D
#ifdef __cplusplus=0D
}=0D
#endif=0D=0D
#endif=0D=0D
=0D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D=

//HelloWorldImp.h=0D
=0D
#if defined(MAKEDLL)=0D
   #  define INTERFACE __declspec(dllexport)=0D
   #elif defined(USEDLL)=0D
   #  define INTERFACE __declspec(dllimport)=0D
   #else=0D
   #  define INTERFACE=0D
   #endif=0D
=0D
INTERFACE=0D
JNIEXPORT void JNICALL =0D
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj); =0D
=0D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=0D
=0D
// HelloWorldImp.c=0D
#include <jni.h>=0D
#include "HelloWorld.h"=0D
#include <stdio.h>=0D
#include "HelloWorldImp.h"=0D
=0D
JNIEXPORT void JNICALL =0D
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) =0D
{=0D
    printf("Hello world!\n");=0D
    return;=0D
}=0D
=0D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D
=0D
=0D
maney AT PC35 /cygdrive/c/JAVAandC++=0D
$ gcc -DMAKEDLL -Ic:/jdk1.3/include -Ic:/jkd1.3/include/win32 -c =
HelloWorldImp.=0D
c -o HelloWorldImp.o=0D
In file included from HelloWorldImp.c:1:=0D
HelloWorldImp.h:10: syntax error before `void'=0D
HelloWorldImp.h:11: parse error before `*'=0D
HelloWorldImp.h:11: warning: data definition has no type or storage =
class=0D
In file included from jni.h:30,=0D
                 from HelloWorldImp.c:2:=0D
jni_md.h:19: parse error before `jlong'=0D
jni_md.h:19: warning: data definition has no type or storage class=0D
In file included from HelloWorldImp.c:2:=0D
jni.h:111: parse error before `jlong'=0D
jni.h:111: warning: no semicolon at end of struct or union=0D
jni.h:115: parse error before `}'=0D
jni.h:115: warning: data definition has no type or storage class=0D
jni.h:258: parse error before `jvalue'=0D
jni.h:273: parse error before `jvalue'=0D
jni.h:280: parse error before `jvalue'=0D
jni.h:287: parse error before `jvalue'=0D
jni.h:294: parse error before `jvalue'=0D
jni.h:301: parse error before `jvalue'=0D
jni.h:308: parse error before `jvalue'=0D
jni.h:310: warning: no semicolon at end of struct or union=0D
jni.h:312: warning: `__stdcall__' attribute directive ignored=0D
jni.h:313: `jlong' declared as function returning a function=0D
jni.h:313: `jlong' redeclared as different kind of symbol=0D
jni_md.h:19: previous declaration of `jlong'=0D
jni.h:313: warning: data definition has no type or storage class=0D
jni.h:314: warning: `__stdcall__' attribute directive ignored=0D
jni.h:315: parse error before `jvalue'=0D
jni.h:315: `jlong' declared as function returning a function=0D
jni.h:315: warning: data definition has no type or storage class=0D
jni.h:322: parse error before `jvalue'=0D
jni.h:329: parse error before `jvalue'=0D
jni.h:336: parse error before `jvalue'=0D
jni.h:345: parse error before `jvalue'=0D
jni.h:354: parse error before `jvalue'=0D
jni.h:363: parse error before `jvalue'=0D
jni.h:372: parse error before `jvalue'=0D
jni.h:381: parse error before `jvalue'=0D
jni.h:390: parse error before `jvalue'=0D
jni.h:392: warning: `__stdcall__' attribute directive ignored=0D
jni.h:393: `jlong' declared as function returning a function=0D
jni.h:393: warning: data definition has no type or storage class=0D
jni.h:394: warning: `__stdcall__' attribute directive ignored=0D
jni.h:396: `jlong' declared as function returning a function=0D
jni.h:396: warning: data definition has no type or storage class=0D
jni.h:397: warning: `__stdcall__' attribute directive ignored=0D
jni.h:399: parse error before `jvalue'=0D
jni.h:399: `jlong' declared as function returning a function=0D
jni.h:399: warning: data definition has no type or storage class=0D
jni.h:408: parse error before `jvalue'=0D
jni.h:417: parse error before `jvalue'=0D
jni.h:426: parse error before `jvalue'=0D
jni.h:443: warning: `__stdcall__' attribute directive ignored=0D
jni.h:444: `jlong' declared as function returning a function=0D
jni.h:444: warning: data definition has no type or storage class=0D
jni.h:463: parse error before `jlong'=0D
jni.h:477: parse error before `jvalue'=0D
jni.h:484: parse error before `jvalue'=0D
jni.h:491: parse error before `jvalue'=0D
jni.h:498: parse error before `jvalue'=0D
jni.h:505: parse error before `jvalue'=0D
jni.h:512: parse error before `jvalue'=0D
jni.h:514: warning: `__stdcall__' attribute directive ignored=0D
jni.h:515: `jlong' declared as function returning a function=0D
jni.h:515: warning: data definition has no type or storage class=0D
jni.h:516: warning: `__stdcall__' attribute directive ignored=0D
jni.h:517: `jlong' declared as function returning a function=0D
jni.h:517: warning: data definition has no type or storage class=0D
jni.h:518: warning: `__stdcall__' attribute directive ignored=0D
jni.h:519: parse error before `jvalue'=0D
jni.h:519: `jlong' declared as function returning a function=0D
jni.h:519: warning: data definition has no type or storage class=0D
jni.h:526: parse error before `jvalue'=0D
jni.h:533: parse error before `jvalue'=0D
jni.h:540: parse error before `jvalue'=0D
jni.h:556: warning: `__stdcall__' attribute directive ignored=0D
jni.h:557: `jlong' declared as function returning a function=0D
jni.h:557: warning: data definition has no type or storage class=0D
jni.h:576: parse error before `jlong'=0D
jni.h:638: parse error before `*'=0D
jni.h:639: warning: data definition has no type or storage class=0D
jni.h:656: parse error before `jlong'=0D
jni.h:673: parse error before `jlong'=0D
jni.h:690: parse error before `jlong'=0D
jni.h:732: parse error before `}'=0D
In file included from HelloWorldImp.c:3:=0D
HelloWorld.h:16: conflicting types for =
`Java_HelloWorld_displayHelloWorld'=0D
HelloWorldImp.h:11: previous declaration of =
`Java_HelloWorld_displayHelloWorld'=0D
=0D
maney AT PC35 /cygdrive/c/JAVAandC++=0D
$

--2f1e_5ed6-3f11_2f5-5656_5acc
Content-Type: text/plain; charset=us-ascii

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
--2f1e_5ed6-3f11_2f5-5656_5acc--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019