luaosx-snow-leopardx86-64luajava

Building LuaJava on OSX Snow Leopard


I am trying to build LuaJava on OSX Snow Leopard and I am getting a linking problem. I have modified the config script for OSX and I have ensured that all of the paths there are correct. I had to change luajava.c(line 2795) to have lua_resume take two LuaStates. This gets it past the building stage but it fails on linking. This is what I get:

export MACOSX_DEPLOYMENT_TARGET=10.6; gcc -dynamiclib -all_load -o libluajava-1.1.jnilib src/c/luajava.o /usr/local/lib/liblua.a
Undefined symbols for architecture x86_64:
  "_luaL_findtable", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1LfindTable in luajava.o
  "_luaL_setn", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1LsetN in luajava.o
  "_luaL_getn", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1LgetN in luajava.o
  "_luaL_typerror", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1Ltyperror in luajava.o
  "_lua_getgccount", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1getGcCount in luajava.o
  "_lua_setfenv", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1setFEnv in luajava.o
  "_lua_getfenv", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1getFEnv in luajava.o
  "_lua_objlen", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1objlen in luajava.o
  "_lua_strlen", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1strlen in luajava.o
  "_lua_lessthan", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1lessthan in luajava.o
  "_lua_equal", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1equal in luajava.o
  "_lua_open", referenced from:
      _Java_org_keplerproject_luajava_LuaState__1open in luajava.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [libluajava-1.1.jnilib] Error 1

Which I don't understand since I just built lua from soruce for this system. Any ideas?


Solution

  • I am not sure what is wrong with your setup, here what I did to compile LuaJava successfully on Mac OS X Lion:

    Download & compile latest Lua 5.1

    $ wget http://www.lua.org/ftp/lua-5.1.5.tar.gz
    $ tar xzf lua-5.1.5.tar.gz
    $ cd lua-5.1.5
    $ make -j macosx
    $ make install
    $ cd ..
    

    Download LuaJava

    $ wget https://github.com/jasonsantos/luajava/zipball/master
    $ mv master luajava.zip
    $ unzip luajava.zip
    $ mv jasonsantos-luajava-32a3fcd/ luajava
    $ cd luajava
    

    Edit the config file

    $ diff -u config.old config
    --- config.old  2007-12-27 08:38:30.000000000 +0100
    +++ config  2012-03-07 20:11:28.000000000 +0100
    @@ -1,11 +1,11 @@
     #############################################################
     #Linux/BSD/Mac
    -LUA_DIR= /usr/local/share/lua/5.1.1
    +LUA_DIR= /usr/local/share/lua/5.1
     LUA_LIBDIR= /usr/local/lib
    -LUA_INCLUDES= /usr/local/include
    -JDK= $(JAVA_HOME)
    +LUA_INCLUDES= -I/usr/local/include -I/System/Library/Frameworks/JavaVM.framework/Headers
    +#JDK= $(JAVA_HOME)
     # For Mac OS, comment the above line and uncomment this one
    -#JDK=/Library/Java/Home
    +JDK=/Library/Java/Home
    
     # Full path to Lua static library
     LIB_LUA=$(LUA_LIBDIR)/liblua.a
    @@ -18,15 +18,15 @@
     LIB_PREFIX= lib
    
     #Linux/BSD
    -LIB_OPTION= -shared
    +#LIB_OPTION= -shared
     #Mac OS
    -#LIB_OPTION= -dynamiclib -all_load
    +LIB_OPTION= -dynamiclib -all_load
    
     ## On FreeBSD and Mac OS systems, the following line should be commented
     DLLIB= -ldl
    
     WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings
    -INCS= -I$(JDK)/include -I$(JDK)/include/linux -I$(LUA_INCLUDES)
    +INCS= -I$(JDK)/include -I$(JDK)/include/linux $(LUA_INCLUDES)
     CFLAGS= $(WARN) $(INCS)
    
     CC= gcc
    

    Compile LuaJava

    $ make
    gcc -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -I/Library/Java/Home/include -I/Library/Java/Home/include/linux -I/usr/local/include -I/System/Library/Frameworks/JavaVM.framework/Headers   -c -o src/c/luajava.o src/c/luajava.c
    ... a million warnings later ...
    export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -dynamiclib -all_load -o libluajava-1.1.so src/c/luajava.o /usr/local/lib/liblua.a
    ------------------
    Build Complete
    ------------------