2015-12-21 120 views
0

对不起,我的英文很差。mips-openwrt-linux-gcc:链接lua lib错误

我想在openwrt 14.07上的c app中调用lua函数。 当交叉编译项目时,我无法在工具链中找到lua的头文件和.so文件。所以我把ubuntu 14.04和liblua.so中的lua51文件夹从目标操作系统复制到工具链中。然后尝试编译该项目,得到未定义的引用错误。

mips-openwrt-linux-gcc airkiss.c luaconf.c -lpthread -llua libairkiss_log.a 
-L. -o airkiss -Wl,-rpath-link=/opt/OpenWrt-Toolchain-ar71xx-for-mips_34kc-gcc-4.8-linaro_uClibc-0.9.33.2/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib 

我得到了错误:

luaconf.c:(.text+0x18): undefined reference to `luaL_newstate' 
luaconf.c:(.text+0x28): undefined reference to `luaL_openlibs' 
luaconf.c:(.text+0x3c): undefined reference to `luaL_loadfile' 
luaconf.c:(.text+0x54): undefined reference to `lua_getfield' 
luaconf.c:(.text+0x64): undefined reference to `lua_pushstring' 
luaconf.c:(.text+0x74): undefined reference to `lua_pushstring' 
luaconf.c:(.text+0x8c): undefined reference to `lua_pcall' 
luaconf.c:(.text+0xa0): undefined reference to `lua_tolstring' 
luaconf.c:(.text+0xc0): undefined reference to `lua_close' 

任何人都知道如何解决它?谢谢!

回答

0

最好的方法是让OpenWrt样式的Makefile项目编译你的代码。

仅供参考,请看feeds/packages/multimedia/xupnpd/Makefile - 它也使用liblua。

这本手册将帮助您:https://wiki.openwrt.org/doc/devel/packages

0

看来Lua是默认配置启用。你可以在你的.config文件中检查CONFIG_PACKAGE_liblua和CONFIG_PACKAGE_lua是否是'y'?

默认情况下,头文件位于staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include和lib文件中,位于staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib。

另外检查你是否做完整的构建之前。