airminer / jnlua

JNLua - Java Native Lua
MIT License
15 stars 5 forks source link

Compile on jnlua on MacOs #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am currenlty trying to compile JNLua 1.0.3 C native code. The goal is to 
provide a shipped interpreter for LDT (http://eclipse.org/koneki/ldt/).

Dowloaded dll for windows works fine, under linux the compilation work fine 
aswell. But on MacOs X, I have a major issue to compile the jnlua lib.

Using GCC, I have the followings errors :
gcc -c -fno-strict-aliasing -m64 -fPIC -O2 -Wall -DNDEBUG -D_REENTRANT 
-DLUA_USE_LINUX 
-I/Developer//SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Ver
sions/1.6.0/Headers -I/tmp/lua-5.2.1/src/ ../jnlua.c
../jnlua.c:133: error: thread-local storage not supported for this target

Some explanation can be find here:
http://lists.apple.com/archives/xcode-users/2006/Jun/msg00550.html

It seems that MacOs doesn't support thread-local storage, maybe jnlua have to 
use a different way to store thread variables.

Marc

Original issue reported on code.google.com by marc.aub...@gmail.com on 11 Feb 2013 at 5:53

GoogleCodeExporter commented 9 years ago
Well you can get it to build with latest mac ports 
if you ate still interested there is already a version I have compiled and 
'Hacked' a bit that will work for the both Mac(x86)/Linux. The same jar (native 
code is build in to the jar) can be used in both OS's with out explicitly 
installing the native C code. 

You can get the code and build from 
https://github.com/buksy/jnlua

This might be what you are looking for. 

Original comment by ayes...@gmail.com on 28 Mar 2013 at 11:05

GoogleCodeExporter commented 9 years ago
I had taken a look on your repo. Make specific code for Linux and Mac OS seems 
interesting and helpful in my case, I will looking forward in this way.
As my goal in to include that in eclipse plugins your resulting jar is not 
appropriate, anyway, thanks for the input.

Original comment by marc.aub...@gmail.com on 29 Mar 2013 at 9:42

GoogleCodeExporter commented 9 years ago
There is no quick solution for this. If you can guarantee that there is only 
one thread in JNLua (native library) at any point in time, you should be able 
to go without thread-local storage, i.e. you can compile these variables with a 
plain static modifier.

Original comment by an...@naef.com on 28 Jul 2013 at 10:18

GoogleCodeExporter commented 9 years ago
After researching this a bit more, a solution may be to upgrade gcc on the Mac 
to a more recent version than 4.2, e.g. 4.6. This should provide the required 
__thread support.

Original comment by an...@naef.com on 29 Jul 2013 at 8:43

GoogleCodeExporter commented 9 years ago
I was able to compile this in mac, including luavm. I linked it with Luajit 2.1 
branch. Attached is my OSX makefile, fix paths before make.

I can also send binaries.

Before running Lua program you must set DYLD_LIBRARY_PATH  to path containing 
64 bit libjvm.dylib:

export 
DYLD_LIBRARY_PATH='/Applications/Xcode.app/Contents/Applications/Application 
Loader.app/Contents/MacOS/itms/java/lib/server/'

or

export DYLD_LIBRARY_PATH='/Applications/SmartSVN 
7.6.app/Contents/PlugIns/JRE/Contents/Home/jre/lib/server/'

-- java.lua test
javavm = require("javavm")
print("javavm require ok")
local vm = javavm.create("-Djava.class.path=jnlua-0.9.6.jar")
print("javavm create done")
System = java.require("java.lang.System")
System.out:println("Hello, world! from Java System.out:println()")
javavm.destroy()

Original comment by patest...@gmail.com on 6 Nov 2013 at 3:11

Attachments: