编译 Lua - 创建 .so 文件? [英] Compiling Lua - create .so files?

查看:28
本文介绍了编译 Lua - 创建 .so 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Centos 6.5 上编译 Lua 5.2.3,编译/安装工作正常.

I am compiling Lua 5.2.3 on Centos 6.5, and the compilation / install works fine.

但是,我还需要用于编译另一个程序的开发库.我通常会这样做:

However, I also need the development libraries for another program to compile. I would usually install these by doing this :

yum install lua-devel

问题是安装 Lua 5.1 共享库,而不是 5.2.3 共享库.

Problem is that installs the Lua 5.1 shared libraries, not the 5.2.3 ones.

可以只使用 Centos 存储库中的 Lua 5.1 运行,但如果让最新版本工作是一件简单的事情(对于知道的人),那么我会感谢有人给我指路.对我来说,Linux 的 makefile 还是有点呃,嗯,你知道的......

I could just run with Lua 5.1 from the Centos repo, but if it's a simple-ish thing (for someone who knows) to make the latest version work then I'd be grateful for someone showing me the way. For me the Linux makefiles are still a little bit er, well, you know...

编辑

我找到了这个网站 - http://lua-users.org/lists/lua-l/2006-10/msg00091.html - 很久以前建议对makefile进行一些更改,但是当我现在运行它们时我得到了这个:

I found this site - http://lua-users.org/lists/lua-l/2006-10/msg00091.html - from a long time ago which suggested some changes to the makefiles, but I get this when i run them now :

gcc -fPIC -o liblua.so -shared lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o 
lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o 
ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o 
liolib.o lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o
/usr/bin/ld: lapi.o: relocation R_X86_64_32 against `luaO_nilobject_' can not be used 
when making a shared object; recompile with -fPIC

注意到我添加了 -fPIC 是徒劳的;错误中提示的链接中没有建议.

noting that I added the -fPIC in a futile gesture; that wasn't suggested in the link just hinted at in the error.

编辑 2 - 解决方案

EDIT 2 - SOLUTION

好的,虽然我最初是自己找到了这个模组,但正是 catwell 保证它有效,这让我坚持了下来.这就是我所做的......

Ok, whilst I'd found this mod myself originally, it was catwell's assurance that it worked that led me to persevere. Here's what I did...

来自 catwell 的链接 我手动编辑了 Makefiles.它很容易理解(正如 catwell 建议的那样,忽略 luaconf.h 模块).

From catwell's link I manually edited the Makefiles. It's easy enough to follow (and as catwell suggests, ignore the luaconf.h mods).

缺少的链接是更改以下行:

The missing link is to change the following line :

src/Makefile
------------
CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS) -fPIC

您将 -fPIC 添加到末尾.

You are adding the -fPIC to the end.

现在似乎可以正常工作了.

Seems to work fine now.

感谢 Etan,但我接受了 catwell 的回答,因为它最直接地导致了解决方案.

Thanks to Etan, but I'm accepting catwell's answer as it led most directly to the solution.

推荐答案

看看如何Arch Linux 做到了.你不应该碰 LUA_ROOT 但补丁的其余部分很好并且相对容易理解.

Look how Arch Linux does it. You should not touch LUA_ROOT but the rest of the patch is good and relatively simple to understand.

不要忘记将 -fPIC 也添加到 CFLAGS(Arch 包 在这里做).

Don't forget to add -fPIC to the CFLAGS too (the Arch package does it here).

这篇关于编译 Lua - 创建 .so 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆