如何在valac中使用liblua52?

时间:2014-08-14 06:48:25

标签: vala ubuntu-14.04 cc lua-5.2

我尝试使用valac编译器在Ubuntu 14.04中编译vala文件,并且:

$ valac -X "-I/usr/include/lua5.2" --pkg lua --pkg gtk+-3.0 main.vala
/home/gabriel/Documents/opera/cpp/tisserand/src/main.vala.c: In function ‘main’:
/home/gabriel/Documents/opera/cpp/tisserand/src/main.vala.c:156:2: warning: ‘g_type_init’  is deprecated (declared at /usr/include/glib-2.0/gobject/gtype.h:667)  [-Wdeprecated-declarations]
  g_type_init ();
  ^
/tmp/ccX2zHVb.o: In function `on_click':
main.vala.c:(.text+0x7c): undefined reference to `luaL_loadstring'
main.vala.c:(.text+0xa7): undefined reference to `lua_pcallk'
/tmp/ccX2zHVb.o: In function `invert':
main.vala.c:(.text+0x153): undefined reference to `lua_tolstring'
main.vala.c:(.text+0x189): undefined reference to `lua_pushstring'
/tmp/ccX2zHVb.o: In function `_vala_main':
main.vala.c:(.text+0x25a): undefined reference to `luaL_newstate'
main.vala.c:(.text+0x279): undefined reference to `lua_close'
main.vala.c:(.text+0x2ab): undefined reference to `luaL_openlibs'
main.vala.c:(.text+0x2cc): undefined reference to `lua_pushcclosure'
main.vala.c:(.text+0x2dd): undefined reference to `lua_setglobal'
collect2: error: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

我已经安装了liblua 5.2,/usr/include/lua5.2已经安装了lauxlib.hlua.hlua.hppluaconf.hlualib.h。什么遗失了?

1 个答案:

答案 0 :(得分:3)

您还需要链接liblua5.2:

valac -X "-I/usr/include/lua5.2" -X -llua5.2 --pkg lua --pkg gtk+-3.0 main.vala