LuaJIT + shared library using iostream header = Undefined symbols.

  • From: Guilherme Vieira <super.driver.512@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 27 Feb 2015 02:01:48 -0300

Hi, everyone.

I'm trying out LuaJIT's FFI module. I'm not using a host program, but
importing a shared library using ffi.load instead, and running Lua code
using the `luajit' command.

However I'm getting undefined symbol errors loading my shared lib, like
this one:

$ luajit main.lua
luajit: main.lua:2: ./lunar.so: undefined symbol: _ZNSt8ios_base4InitD1Ev
stack traceback:
        [C]: in function 'load'
        main.lua:2: in main chunk
        [C]: at 0x004049c0

More information:

   - LuaJIT version: 2.0.3.
   - GCC version: 4.6.3 (used to compile both LuaJIT and my shared library).
   - Shared library GCC invocation: `gcc -shared -fPIC -Wall lunar.cpp -o
   lunar.so'.
   - Lua program invocation: `luajit main.lua'.
   - main.lua / lunar.cpp sources and invocation strace:
   gist.github.com/n2liquid/a71d086d38afae3dd6dc.

I really couldn't find information about this searching the web (still a
newb, so I probably don't know how to search properly). Most Q&As revolved
around using a C host program, but like I said, that's not my case.

If I simply remove `#include <iostream>' from lunar.cpp, it works just fine.

Can someone please help?

Atenciosamente / Sincerely,
Guilherme Prá Vieira

<http://www.linkedin.com/in/n2liquid>
<http://www.linkedin.com/in/n2liquid>

Other related posts: