CygwinでのJNIコンパイル2
int渡しはなんとか動いたが、文字列渡しでコンパイル通らず。
そんな構造体ないって。。。なんかつまずくなコレ。
きっとJavaならメソッドがありませんみたいな初歩的エラーなんだろな。
gcc -mno-cygwin -D__int64='long long' -I"C:\Program Files\Java\jdk1.5.0_07\include" -I"C:\Program Files\Java\jdk1.5.0_07\include\win32" -Wl,--add-stdcall-alias -shared -o HelloJNI.dll HelloJNI.c
ソース
#include <stdio.h> #include "hoge_HelloJNI.h" JNIEXPORT jstring JNICALL Java_hello_HelloJNI_sayHello (JNIEnv *env, jclass clazz) { return env->NewStringUTF("Hello"); } JNIEXPORT jint JNICALL Java_hoge_HelloJNI_count (JNIEnv *env, jclass clazz, jint num) { return num + 1; }
コンパイルエラー
HelloJNI.c:7: error: request for member `NewStringUTF' in something not a struct ure or union
参考
http://www.inonit.com/cygwin/jni/helloWorld/c.html
http://sohda.net/cygwin/java.html
http://cappuccino.jp/keisuken/java/jni.html