linux编译lua,Linux CentOS 编译LUA。。搞半天终于对了= =

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

安装 wget http://www.lua.org/ftp/lua-5.2.1.tar.gz

tar -zvxf lua-5.2.1.tar.gz

make linux

错误:gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lua.o lua.clua.c:67:31: error: readline/readline.h: No such file or directorylua.c:68:30: error: readline/history.h: No such file or directorylua.c: In function ‘pushline’:lua.c:271: warning: implicit declaration of function ‘readline’lua.c:271: warning: assignment makes pointer from integer without a castlua.c: In function ‘loadline’:lua.c:301: warning: implicit declaration of function ‘add_history’make[2]: *** [lua.o] Error 1make[2]: Leaving directory `/root/lua-5.2.0/src'make[1]: *** [linux] Error 2make[1]: Leaving directory `/root/lua-5.2.0/src'make: *** [linux] Error 2

解决:yum install -y readline-devel ncurses-devel

#include

#include"lua.h"

#include"lauxlib.h"

#include"lualib.h"

#include "luaconf.h"

int main(){ lua_State *L; L = luaL_newstate(); luaL_openlibs(L); luaL_dofile(L,"test.lua"); lua_close(L);}

运行: gcc -o test tes.c -I/usr/local/lua/include/ -L/usr/local/lua/lib/ /usr/local/lua/lib/liblua.a -llua -lm -ldl

错误1:没有引用liblua.a

/tmp/cckH9huG.o: In function `main':tes.c:(.text+0x12): undefined reference to `luaL_newstate'tes.c:(.text+0x20): undefined reference to `luaL_openlibs'tes.c:(.text+0x33): undefined reference to `luaL_loadfile'tes.c:(.text+0x5a): undefined reference to `lua_pcall'tes.c:(.text+0x65): undefined reference to `lua_close'collect2: ld returned 1 exit status

错误2:没有引用数学库 -llua -lm

/usr/local/lua/lib/liblua.a(lvm.o): In function `Arith':lvm.c:(.text+0xbdb): undefined reference to `pow'/usr/local/lua/lib/liblua.a(lvm.o): In function `luaV_execute':lvm.c:(.text+0x20b7): undefined reference to `pow'/usr/local/lua/lib/liblua.a(lcode.o): In function `codearith':lcode.c:(.text+0x11ec): undefined reference to `pow'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_tan':lmathlib.c:(.text+0x1ee): undefined reference to `tan'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_tanh':lmathlib.c:(.text+0x22e): undefined reference to `tanh'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_sqrt':lmathlib.c:(.text+0x27d): undefined reference to `sqrt'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_sin':lmathlib.c:(.text+0x2be): undefined reference to `sin'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_sinh':lmathlib.c:(.text+0x2fe): undefined reference to `sinh'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_pow':lmathlib.c:(.text+0x488): undefined reference to `pow'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_log':lmathlib.c:(.text+0x52e): undefined reference to `log'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_log10':lmathlib.c:(.text+0x56e): undefined reference to `log10'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_fmod':lmathlib.c:(.text+0x678): undefined reference to `fmod'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_exp':lmathlib.c:(.text+0x6be): undefined reference to `exp'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_cos':lmathlib.c:(.text+0x6fe): undefined reference to `cos'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_cosh':lmathlib.c:(.text+0x73e): undefined reference to `cosh'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_atan':lmathlib.c:(.text+0x77e): undefined reference to `atan'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_atan2':lmathlib.c:(.text+0x7d8): undefined reference to `atan2'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_asin':lmathlib.c:(.text+0x81e): undefined reference to `asin'/usr/local/lua/lib/liblua.a(lmathlib.o): In function `math_acos':lmathlib.c:(.text+0x85e): undefined reference to `acos'/usr/local/lua/lib/liblua.a(loadlib.o): In function `ll_loadfunc':loadlib.c:(.text+0x947): undefined reference to `dlsym'loadlib.c:(.text+0x954): undefined reference to `dlerror'loadlib.c:(.text+0xa2c): undefined reference to `dlopen'loadlib.c:(.text+0xa41): undefined reference to `dlerror'/usr/local/lua/lib/liblua.a(loadlib.o): In function `gctm':loadlib.c:(.text+0x104e): undefined reference to `dlclose'collect2: ld returned 1 exit status

错误3:没有用-ldl 没找着这个是干什么用的,看起来像device

/usr/local/lua/lib/liblua.a(loadlib.o): In function `ll_loadfunc':loadlib.c:(.text+0x947): undefined reference to `dlsym'loadlib.c:(.text+0x954): undefined reference to `dlerror'loadlib.c:(.text+0xa2c): undefined reference to `dlopen'loadlib.c:(.text+0xa41): undefined reference to `dlerror'/usr/local/lua/lib/liblua.a(loadlib.o): In function `gctm':loadlib.c:(.text+0x104e): undefined reference to `dlclose'collect2: ld returned 1 exit status

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值