From: SourceForge.net <no...@so...> - 2004-05-11 21:43:00
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2564757 By: gnulrich1 Hi, I don't manage to write a hello-world-program, which uses Java, C and CNI. --- package ulrich --- The package ulrich is in the path D:\ and contains the Java-declarations and the native C-code: *** D:\ulrich\ShCNI.java *** package ulrich; public class ShCni { public static native void hello(); public static native void world(); } *** end *** *** D:\ulrich\ShCni.cc *** #include "ShCni.h" #include <stdio.h> #include <gcj/cni.h> void ulrich::ShCni::hello () { printf( "ulrich::ShCni::hello\n" ); } void ulrich::ShCni::world () { printf( "ulrich::ShCni::world\n" ); } *** end *** I compiled ShCni.java to get ShCni.o: gcj -c -g -O ShCni.java I compiled ShCni.java to get ShCni.class: gcj -C ShCni.java I used ShCni.class to get ShCni.h: gcjh ShCni I compiled ShCni.cc to get Native.o: gcc -o Native.o -c ShCni.cc --- package app --- The package app is in the path D:\ and contains the Java-app: *** D:\app\App.java *** package app; import ulrich.*; public class App { public static void main( String[] args ) { System.out.println( "app.App.main" ); ShCni.hello(); ShCni.world(); } } *** end *** I tried to compiled App.java to get App.exe: gcj --main=app.App -o App ../ulrich/Native.o ../ulrich/ShCni.o App.java The error-message is: App.java:11: error: Can't find method `world()' in type `ulrich.ShCni'. ShCni.world(); ^ 1 error gcj finds obviously method ShCni.hello(); Why can't gcj find method ShCni.world(); ? If I delete ShCni.world(); in App.java everything works well and App.exe gives out: app.App.main ulrich::ShCni::hello Thanks Ulrich PS: Maybe my installation of MinGW is not correct, because I don't know, how to install it correctly, see topic: 'How to install MinGW correctly'. ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=286533 |