最后我编译了它。主要错误是关于VS环境变量。要编译和链接正确我需要输入
%VisualStudoFolder%\VC\vcvarsall.bat amd64 nmake -f makefile
默认的LuaJava发行版仅提供32位二进制文件。显然,将它们与64位VM \ OS一起使用会导致异常。
此外,我不能只将Lua二进制文件更改为64位,因为这会导致
Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.keplerproject.luajava.LuaState._open()Lorg/keplerproject/luajava/CPtr;
我不知道为什么会这样,Google也没有帮助我。
我已经确定这是因为64位和32位的库完全不同,所以我必须重新编译LuaJava并自己进行链接。
我从SourceForge的Lua repo下载了源代码(luabinaries / files / 5.1.4 / Windows%20Libraries /)(顺便说一句,我试过不同的版本,但我没有成功),安装了MSVS以使用nmake
实用程序与Makefiles。最后,我遵循了“LuaJava手册”的指南,但我只得到了这个:
...\luajava-1.1>nmake -f makefile
"
#Here was java-files compilation logs
#C compilation
cl -nologo -DWIN32 -I"C:\Program Files\Java\jdk1.7.0_21\/include" -I"C:\Program Files\Java\jdk1.7.0_21\/include/win32" -I"P:\Lua\include" -Fosrc\C\\ -MD /c src\c\luajava.c luajava.c
link /dll /nodefaultlib:"msvcrt.lib" -out:luajava-1.1.dll src\c\luajava.obj P:\Lua\lib\lua5.1.lib
Microsoft (R) Incremental Linker Version 12.00.20827.3
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library luajava-1.1.lib and object luajava-1.1.exp
luajava.obj : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _Java_org_keplerproject_luajava_LuaState_luajava_1open@16
luajava.obj : error LNK2019: unresolved external symbol __imp__fprintf referenced in function Java_org_keplerproject_luajava_LuaState_luajava_1open@16
luajava.obj : error LNK2019: unresolved external symbol __imp__exit referenced in function Java_org_keplerproject_luajava_LuaState_luajava_1open@16
luajava.obj : error LNK2001: unresolved external symbol "__fltused"
LINK : error LNK2001: unresolved external symbol "__DllMainCRTStartup@12"
luajava-1.1.dll : fatal error LNK1120: 5 unresolved externals
NMAKE : fatal error U1077: "P:\MS Visual Studio 2010\VC\BIN\link.EXE" : return code "0x460"
Stop.
所以问题是如何解决这个问题(希望它至少能与LuaStateFactory.newLuaState().openLibs()
一起使用)?
答案 0 :(得分:0)
我遇到过这个问题,但后来解决了。这是解决方案。
我设法编译了64位luajava-64.dll,64位luajava-64.so,32位动态链接库,依此类推。
以下是步骤。
1. Install vs2010
2. Locate vs2010-visual studio tools
Open visual studio x64 Win64 Command Prompt tool
3. Download lua-5.1.5_Win64_vc10_lib.zip
. (Static library wrong key point is that this static library may download error, or you download as a dynamic library dll, download address: lua static library download:
http://sourceforge.net/projects/luabinaries/files/5.1.5/Windows%20Libraries/Static/)
Download luajava-1.1.zip
4. Open config.win modify LUA_DIR and JDK two paths for their own path
Note that you may not have your LUA_DIR below lib directory, then create your own needs and into which lua5.1.lib
5. cd enter luajava-1.1 directory
6. Run nmake -f Makefile.win
7. Compile success
Here is the situation at compile time:
C: \ Users \ softm \ Desktop \ luajava \ luajava-1.1> nmake -f Makefile.win
Microsoft (R) Program Maintenance Utility 10.00.30319.01 version
Copyright (C) Microsoft Corporation. All rights reserved.
"D: \ soft \ Java \ jdk6_33 \ bin \ javac" -sourcepath ./src/java src / java / org / kep
lerproject / luajava / CPtr.java
"D: \ soft \ Java \ jdk6_33 \ bin \ javac" -sourcepath ./src/java src / java / org / kep
lerproject / luajava / JavaFunction.java
Note: Some input files use unchecked or unsafe operations.
Note: For more information, please use the -Xlint: unchecked recompiled.
"D: \ soft \ Java \ jdk6_33 \ bin \ javac" -sourcepath ./src/java src / java / org / kep
lerproject / luajava / LuaJavaAPI.java
Note: Some input files use unchecked or unsafe operations.
Note: For more information, please use the -Xlint: unchecked recompiled.
"D: \ soft \ Java \ jdk6_33 \ bin \ javac" -sourcepath ./src/java src / java / org / kep
lerproject / luajava / Console.java
Note: Some input files use unchecked or unsafe operations.
Note: For more information, please use the -Xlint: unchecked recompiled.
cd src / java
"D: \ soft \ Java \ jdk6_33 \ bin \ jar" cvf ../../luajava-1.1.jar org / keplerproje
ct / luajava / *. class
Marked list (manifest)
Increase: org / keplerproject / luajava / Console.class (read = 1921) (write = 1122) (compressed 41
%)
Increase: org / keplerproject / luajava / CPtr.class (read = 510) (write = 359) (29% compression)
Increase: org / keplerproject / luajava / JavaFunction.class (read = 942) (write = 524) (compressed
44%)
Increase: org / keplerproject / luajava / LuaException.class (read = 556) (write = 352) (compressed
36%)
Increase: org / keplerproject / luajava / LuaInvocationHandler.class (read = 1621) (written = 83
3) (48% compression)
Increase: org / keplerproject / luajava / LuaJavaAPI.class (read = 7168) (write = 3745) (compressed
47%)
Increase: org / keplerproject / luajava / LuaObject.class (read = 9045) (write = 3978) (compressed
56%)
Increase: org / keplerproject / luajava / LuaState.class (read = 18118) (write = 6435) (compressed
64%)
Increase: org / keplerproject / luajava / LuaStateFactory.class (read = 1293) (write = 722) (Pressure
Reduced by 44%)
cd ..
cd ..
"D: \ soft \ Java \ jdk6_33 \ bin \ javadoc" -classpath "src / java /" -public -quiet
-d "doc / us / API" src / java / org / keplerproject / luajava / JavaFunction.java src / java /
org / keplerproject / luajava / LuaException.java src / java / org / keplerproject / luajava /
LuaInvocationHandler.java src / java / org / keplerproject / luajava / LuaObject.java sr
c / java / org / keplerproject / luajava / LuaState.java src / java / org / keplerproject / luaja
va / LuaStateFactory.java src / java / org / keplerproject / luajava / Console.java
"D: \ soft \ Java \ jdk6_33 \ bin \ javah" -o src / c / luajava.h -classpath "luajava-
1.1.jar "org.keplerproject.luajava.LuaState
cl -nologo -DWIN32 -I "D: \ soft \ Java \ jdk6_33 / include" -I "D: \ soft \ Java \ jdk6
_33 / Include / win32 "-I" C: \ Users \ softm \ Desktop \ luajava \ lua \ include "-Fosrc \ C \\ -MD
/ c src \ c \ luajava.c
luajava.c
link / dll /nodefaultlib:"msvcrt.lib "-out: luajava-1.1.dll src \ c \ luajava
.obj C: \ Users \ softm \ Desktop \ luajava \ lua \ lib \ lua5.1.lib
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library luajava-1.1.lib and objects luajava-1.1.exp
luajava.obj: warning LNK4217: locally defined symbol exit function Java_org_keplerproject
Import _luajava_LuaState_luajava_1open
luajava.obj: warning LNK4217: locally defined symbol fprintf function Java_org_keplerproj
Import ect_luajava_LuaState_luajava_1open
luajava.obj: warning LNK4217: locally defined symbol __iob_func function Java_org_keplerp
Import roject_luajava_LuaState_luajava_1open
del src \ java \ org \ keplerproject \ luajava \ *. class src \ c \ *. obj * .pdb * .exp *
.lib * .exp * .ilk
------------------
Build Complete
------------------