This problem has stucked me for days. I have very few knowledge on C, recently I downloaded "jnlua-0.9.6-src.zip" from "https://code.google.com/p/jnlua/downloads/list" and try to compile jnlua.c with following command:
mingw32-gcc -m32 -O2 -c -o jnlua.o jnlua.c -Id:\luarock\lua -Id:\java\include\win32 -Id:\java\include
As a result, the compiler prints several screens of error messages, below are some of them:
jnlua.c:120:1: error: unknown type name 'JNLUA_THREADLOCAL'
JNLUA_THREADLOCAL JNIEnv *thread_env;
^
jnlua.c:120:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
JNLUA_THREADLOCAL JNIEnv *thread_env;
^
jnlua.c:138:1: error: unknown type name 'JNLUA_THREADLOCAL'
JNLUA_THREADLOCAL jobject newstate_obj;
^
jnlua.c:138:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'newstate_obj'
JNLUA_THREADLOCAL jobject newstate_obj;
^
jnlua.c: In function 'newstate_protected':
jnlua.c:148:11: error: 'thread_env' undeclared (first use in this function)
*ref = (*thread_env)->NewWeakGlobalRef(thread_env, newstate_obj);
^
jnlua.c:148:11: note: each undeclared identifier is reported only once for each function it appears in
jnlua.c:148:53: error: 'newstate_obj' undeclared (first use in this function)
*ref = (*thread_env)->NewWeakGlobalRef(thread_env, newstate_obj);
^
jnlua.c: In function 'Java_com_naef_jnlua_LuaState_lua_1newstate':
jnlua.c:31:2: error: 'thread_env' undeclared (first use in this function)
thread_env = env;\
^
jnlua.c:188:2: note: in expansion of macro 'JNLUA_ENV'
JNLUA_ENV(env);
I'm sure that the include paths are correct, no idea why this happens. Highly appreciated that someone can help, I really need to compile it into dll file because the prebuild dll doesn't support windows XP.
Update on 22-Mar: My problem is finally resolved by following command, thanks for help:
gcc -m32 -Wl,--add-stdcall-alias -shared -O2 -o jnlua5.1.dll jnlua.c lua5.1.dll -DLUA_WIN -DLUA_BUILD_AS_DLL -Id:\luarock\lua -Id:\java\include\win32 -Id:\java\include -static -s