Shared Library 사용중의 undefined symbol 문제

김영현의 이미지

현재 개발된 프로그램을 lua를 사용해 test 하려고 합니다. 그래서, lua engine을 shared library로 만들었고, 기존의 c/c++로 만들어진 프로그램의 인터페이스에 해당하는 부분을 swig을 사용해 wrapper.so를 만들었습니다. 대략적인 dependency는 다음과 같습니다.

executable -- loads --> lua_engine.so -- loads --> wrapper.so

문제는 wrapper.so 는 lua_pushvalue와 같은 lua에서 제공하는 함수의 구현을 가지고 있지 않습니다. lua_engine.so가 모든 lua관련 api를 가지고 있습니다.

lua_engine.so를 로드 한 후 lua engine을 실행하여 lua prompt에 다음과 같은 코드를 입력하면...

lua>> require "wrapper" // wrapper.so를 dlopen(wrapper.so, RTLD_NOW) 로 로드하는 것과 같은 코드 입니다.

다음의 에러가 발생합니다.

error loading module 'wrapper' from file 'wrapper.so'
wraper.so: undefined symbol: lua_getmetatable

lua_getmetatable이 없다는 것인데.. nm을 사용해 lua_engine.so를 살펴 보면 lua_getmetatable에 심볼이 존재합니다.

왜? executable에 로드된 lua_engine.so의 심볼을 wrapper.so에서 찾지 못하는지 모르겠습니다.

고수님들 답변 부탁드립니다.