At this point in asterisk, you're trying to build a dynamic lib. Since this dynamic lib can be loaded at any memory location, everything needs to be relocatable. The -fPIC
flag means Position Independent Code, the code is made to be independent of load location - loaded anywhere.
As part of this asterisk dynamic lib build, it's trying to bring in the Lua interpreter. Since it's bringing into a dynamic lib, it needs everything compiled PIC. But you're using a static lib of lua, which was not built with -fPIC. It rejects this, since the lua objects in the static lib can not be relocated.
BTW: this is why adding -fPIC
to the asterisk build won't help. It's not your asterisk code objects that are incompatible (which -fPIC can affect), but liblua.a, specifically the objects carried by liblua.a (e.g lapi.o). Besides, you're building a dynamic lib at that point, and Im sure you already have relocatable code flags such as -fPIC for the asterisk objects you're trying to pull together at that point.
I see three solutions.
One is to drop lua from your build. If you don't need it specifically and were thinking more that "this may be fun to play with later" you may be able to and not lose wanted features.
Another is to get a dynamic version of liblua,
liblua.so
, one that can be referenced in your asterisk build. I don't know your distro, so I can't say how to get it.The other, more pain in the ass one, is to rebuild lua, and liblua.a, with -fPIC. You'd have compatibility issues maybe from inconsistent build flags (what you made and what else is on disk), so I think finding a liblua.so to match your currently built lua is the better option.
If you find liblua.so, you may want to look into the '-rpath' linker flag for this though, specifically '-Wl,-rpath,/path/to/lua/libs'