lua编译问题总结

1、首先安装lua

linux系统

make linux

make install


2、编译


gcc -lm  -g -o test test.c /usr/local/lib/liblua.a -ldl


如果少-ldl,那么编译就会报:

gcc -lm  -g -o test test.c /usr/local/lib/liblua.a 

/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0x35): undefined reference to `dlclose'
/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0xc0): undefined reference to `dlopen'
loadlib.c:(.text+0xfc): undefined reference to `dlsym'
loadlib.c:(.text+0x198): undefined reference to `dlerror'
loadlib.c:(.text+0x1bb): undefined reference to `dlerror'



如果少liblua.a ,就会报如下问题:

[wangbin@tuan lua]$ gcc -lm  -g -o test test.c  -ldl                       
/tmp/ccCT0d24.o: In function `main':
/home/wangbin/work/tmp/lua/test.c:26: undefined reference to `luaL_newstate'
/home/wangbin/work/tmp/lua/test.c:27: undefined reference to `luaL_openlibs'
/home/wangbin/work/tmp/lua/test.c:29: undefined reference to `luaL_loadbufferx'
/home/wangbin/work/tmp/lua/test.c:29: undefined reference to `lua_pcallk'
/home/wangbin/work/tmp/lua/test.c:32: undefined reference to `lua_tolstring'
/home/wangbin/work/tmp/lua/test.c:33: undefined reference to `lua_settop'
/home/wangbin/work/tmp/lua/test.c:36: undefined reference to `lua_close'
collect2: ld returned 1 exit status


如果少-lm,那么编译结果如下:

[wangbin@tuan lua]$ gcc -g -o test test.c /usr/local/lib/liblua.a -ldl
/usr/local/lib/liblua.a(lobject.o): In function `luaO_arith':
lobject.c:(.text+0xdf): undefined reference to `pow'
/usr/local/lib/liblua.a(lvm.o): In function `luaV_execute':
lvm.c:(.text+0x159a): undefined reference to `pow'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_sin':
lmathlib.c:(.text+0x3e): undefined reference to `sin'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_sinh':
lmathlib.c:(.text+0x6e): undefined reference to `sinh'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_cos':
lmathlib.c:(.text+0x9e): undefined reference to `cos'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_cosh':
lmathlib.c:(.text+0xce): undefined reference to `cosh'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_tan':
lmathlib.c:(.text+0xfe): undefined reference to `tan'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_tanh':
lmathlib.c:(.text+0x12e): undefined reference to `tanh'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_asin':
lmathlib.c:(.text+0x15e): undefined reference to `asin'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_acos':
lmathlib.c:(.text+0x18e): undefined reference to `acos'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_atan':
lmathlib.c:(.text+0x1be): undefined reference to `atan'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_atan2':
lmathlib.c:(.text+0x1fb): undefined reference to `atan2'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_fmod':
lmathlib.c:(.text+0x2db): undefined reference to `fmod'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_sqrt':
lmathlib.c:(.text+0x391): undefined reference to `sqrt'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_pow':
lmathlib.c:(.text+0x3d3): undefined reference to `pow'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_log':
lmathlib.c:(.text+0x450): undefined reference to `log'
lmathlib.c:(.text+0x460): undefined reference to `log'
lmathlib.c:(.text+0x486): undefined reference to `log10'
lmathlib.c:(.text+0x4aa): undefined reference to `log'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_log10':
lmathlib.c:(.text+0x4de): undefined reference to `log10'
/usr/local/lib/liblua.a(lmathlib.o): In function `math_exp':
lmathlib.c:(.text+0x50e): undefined reference to `exp'
collect2: ld returned 1 exit status




发布了129 篇原创文章 · 获赞 147 · 访问量 41万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览