lua-users home
lua-l archive

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


On Thu, Feb 23, 2012 at 2:45 PM, Gaspard Bucher <gaspard@teti.ch> wrote:
Hi there,

I am porting lubyk to Linux and I am stuck with undefined symbols. Here is my scenario:

lib/lubyk/core.so contains the symbols for TimeRef class, including (nm output):

00004734 T _ZN5lubyk7TimeRef7elapsedEv
000046a0 T _ZN5lubyk7TimeRefC1Ev
000046a0 T _ZN5lubyk7TimeRefC2Ev
00004704 T _ZN5lubyk7TimeRefD1Ev
00004704 T _ZN5lubyk7TimeRefD2Ev

lib/lubyk/Worker.so uses the TimeRef class.

Doing this fails under Linux but works in Mac OS X:

> require 'lubyk.core'
Loaded again lubyk.core.
---> 0.001955           ---- Here I try to use TimeRef from lua_open_lubyk_core and it works fine.
> require 'lubyk.Worker'
error loading module 'lubyk.Worker' from file '/home/gaspard/git/lubyk/deploy/linux/lib/lubyk/Worker.so':
/home/gaspard/git/lubyk/deploy/linux/lib/lubyk/Worker.so: undefined symbol: _ZN5lubyk7TimeRef7elapsedEv

I am clueless: it seems the loaded Worker.so does not find an already used symbol in the active binary...

The problem is that this is not "normal" behavior for shared libraries (to peek inside the running app to get it's code). This can be enabled by adding "RTLD_GLOBAL" in loadlib.c with:

dlopen(path, RTLD_NOW|RTLD_GLOBAL); 

But instead of using a custom lua, I will see if I can remove these dependency chains.

Gaspard