lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, May 19, 2008 at 9:32 AM, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Mon, May 19, 2008 at 4:07 AM, Mike Pall <mikelu-0805@mike.de> wrote:
>  > Alexander Gladysh wrote:
>  >  > This works with plain Lua, but doesn't with LuaJIT. In LuaJIT that
>  >  > require() call returns true instead of my module's table. Am I missing
>  >  > something?
>  >
>  >  This is not LuaJIT's fault. You're simply not building the module
>  >  the right way.
>  >
>  >  According to the Makefile you provided, you're linking the module
>  >  _itself_ against whatever liblua is found in /opt/local/lib. This
>  >  makes a forward reference to this library (or a copy of it for a
>  >  static library). In your case this is probably the shared library
>  >  of an installed copy of Lua (and not LuaJIT).
>
>  <Helpful detailed explanation skipped>
>
>  Oh. I knew there is something wrong with my makefile. :-(

For the record, here is fixed premake file. All works like a charm now.

  package.name = "mod"
  package.kind = "dll"
  package.language = "c"
  package.files = { "mod.c" }
  --package.links = { "lua" } -- This line is a root of all evil
  table.insert(package.buildflags, { "extra-warnings", "fatal-warnings" })
  package.targetprefix = ""
  if macosx then
    -- I missed that '-undefined dynamic_lookup' thing
    table.insert(package.linkoptions, "-bundle -undefined dynamic_lookup")
    table.insert(package.libpaths, "/opt/local/lib") -- Ports default
installation
  end

LuaJIT sped up my complex processing of 727787 lines of text from 11
to 5 minutes! I'm sure if I didn't have to call my silly bit-fiddling
C-module 160 times per line, I would gain even more. (But I'm happy
with current timing, so this is not an issue.)

Thanks again,
Alexander.