安装luaxml出错relocation R_X86_64_32 against `luaO_nilobject_’

安装luaxml出错relocation R_X86_64_32 against `luaO_nilobject_’

/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: error adding symbols: Bad value

这是在64位linux系统中会出现的问题。意思需要用-fPIC来重新编译 LuaXML_lib.c

但是当你查看makefile的时候,会明确看到已经增加了-fPIC,不知道怎么回事还是不行

# 2009-03-16 by gf

# generic compiler and linker settings:
CC     = gcc
INCDIR = -I../lua/src
LIB    =
LIBDIR =  -L. -L../lua/src
CFLAGS = -Os -Wall -c #-g

# generic platform specific rules:
ARCH            = $(shell uname -s)
ifeq ($(ARCH),Linux)
  CFLAGS += -fPIC
  LFLAGS =  -fPIC -shared
  LIBS          = $(LIBDIR) $(LIB) -llua -ldl
  EXESUFFIX =
  SHLIBSUFFIX = .so

所以这个时候要把makefile里面的Lib代码注释掉,如下改变

# 2009-03-16 by gf

# generic compiler and linker settings:
CC     = gcc
#INCDIR = -I../lua/src
INCDIR = -I/usr/include/lua5.1  #这个位置做了变化,解释在下面
LIB    =
#LIBDIR =  -L. -L../lua/src
LIBDIR =  -L. -L/usr/lib/x86_64-linux-gnu #这个位置做了变化,解释在下面
FLAGS = -Os -Wall -c #-g

# generic platform specific rules:
ARCH            = $(shell uname -s)
ifeq ($(ARCH),Linux)
  CFLAGS += -fPIC
  LFLAGS =  -fPIC -shared
#  LIBS          = $(LIBDIR) $(LIB) -llua -ldl #####就是这行代码注释掉
  EXESUFFIX =
  SHLIBSUFFIX = .so

else

参考出处;http://lua.2524044.n2.nabble.com/Error-while-building-LuaXml-td7654576.html

http://blog.csdn.net/dc_show/article/details/38957991,同时参考了这个文章

http://blog.csdn.net/dc_show/article/details/37722647

使用查找命令:find / -name ‘lua.h’,然后要替换makefile里面的头文件的目录和库文件的目录

find / -name ‘lualib*.a’

Comments are closed.