【发布时间】:2015-04-13 10:04:21
【问题描述】:
这个问题困扰了我好几天。 我对C的了解很少,最近我从“https://code.google.com/p/jnlua/downloads/list”下载了“jnlua-0.9.6-src.zip”并尝试使用以下命令编译jnlua.c:
mingw32-gcc -m32 -O2 -c -o jnlua.o jnlua.c -Id:\luarock\lua -Id:\java\include\win32 -Id:\java\include
因此,编译器会打印几个屏幕的错误消息,下面是其中的一些:
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);
我确定包含路径是正确的,不知道为什么会发生这种情况。 非常感谢有人可以提供帮助,我真的需要将它编译成 dll 文件,因为 prebuild dll 不支持 windows XP。
3 月 22 日更新: 我的问题终于通过以下命令解决了,感谢帮助:
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
【问题讨论】:
-
"nmake" 在 Visual Studio 中也不能使用它的 makefile。