2015-12-21 116 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。

另外檢查你是否做完整的構建之前。