Fehler beim erneuten Kompilieren mit -fPIC

7117
Bilal

Nach einem ./configureSternchen in CentOS gebe ich den Befehl make ein, erhalte jedoch den folgenden Fehler

/usr/bin/ld: /usr/local/lib/liblua.a(lapi.o): relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/liblua.a: could not read symbols: Bad value 

Ich habe dies versucht, ./configure CFLAGS=-fPICaber die gleiche Fehlermeldung wie oben erhalten.

3

1 Antwort auf die Frage

3
Rich Homolka

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'

Ich habe Lösung Nr. 1 angewendet und es hat gut funktioniert. Vielen Dank für Ihre Hilfe. Bilal vor 11 Jahren 0
@BilalWaheed Wenn es funktioniert hat, markieren Sie die Antwort als akzeptiert. Kein Problem bei der Hilfe. Rich Homolka vor 11 Jahren 0