Tags
build, Lua, Lua5.3, pkg-config, QEMU, serialICE, tutorial, ubuntu, Ubuntu14.04
I ran into this issue while trying to build serialICE on Ubuntu 14.04. Ubuntu’s pkg-config was unable to detect a package that I had to manually compile and install Lua5.3. This lead to serialICE’s build.sh to fail.
Usually Ubuntu’s package management tools (apt-get, dpkg, etc) do a good job of updating dependencies, package paths, environment variables and other “under-the-hood” stuff. However, sometimes we need package versions which are not synced with Ubuntu’s package management and search tools yet. In such cases, we need to download the source code, build it, install it in /usr/local/bin or /usr/bin (usually, not always, the case) and last, but not the least, manually update Ubuntu’s package search (pkg-config) to detect it.
SerialICE’s build.sh script required me to install Lua5.3 for it to proceed any further. Since Ubuntu’s apt-get repository system for 14.04 was only updated till Lua5.2 , I couldn’t get Lua5.3 repo using apt-get install. I’ve listed below the steps I took to get it working with small descriptions as and when required.
- Get source code from Lua’s website (http://www.lua.org/download.html). Download lua-5.3.1.tar.gz
- Build and install it.
tar -xzvf lua-5.3.1.tar.gz cd lua-5.3.1 make linux make linux install
- Check that binaries and headers are copied as part of installation in proper directories. The following should exist
/usr/local/bin/lua , /usr/local/include/<lua headerfiles>, /usr/local/lib/liblua.a , /usr/local/man/man1/lua , /usr/local/share/lua/5.3, /usr/local/lib/lua/5.3
- Open lua -v in a terminal – It should say 5.3.1
- Check if pkg-config detects it already : pkg-config –exists lua.
- If not, then we need to add lua.pc file with meta-data and information about lua for pkg-config to detect. We can add lua.pc to default search path (either /usr/lib/pkgconfig or /usr/share/pkgconfig) or update PKG_CONFIG_PATH=/to/package’s/lua.pc containing folder. This is lua.pc I wrote up. Feel free to use it as a template, with tweaks if required.
# This file has been manually written by Arpita Biswas for Lua5.3 prefix=/usr/local exec_prefix=${prefix} includedir=${prefix}/include datarootdir=${prefix}/share libdir=${prefix}/lib Name: lua Description: Lua is a powerful, fast, lightweight, embeddable scripting language. Version: 5.3.1 Cflags: -I${includedir} Libs: -L${libdir} -llua -lm -ldl URL: http://www.lua.org/about.html
Note : In case you get these errors check if you have -lm and -ldl as flags :
/usr/local/lib/liblua.a(lobject.o): In function `numarith.isra.0': lobject.c:(.text+0x123): undefined reference to `fmod' lobject.c:(.text+0x149): undefined reference to `pow' lobject.c:(.text+0x15d): undefined reference to `floor' /usr/local/lib/liblua.a(lvm.o): In function `luaV_tointeger': lvm.c:(.text+0x1ff): undefined reference to `floor' /usr/local/lib/liblua.a(lvm.o): In function `luaV_execute': lvm.c:(.text+0x1af0): undefined reference to `floor' lvm.c:(.text+0x20c7): undefined reference to `pow' lvm.c:(.text+0x215a): undefined reference to `fmod'
- And finally run build.sh to get the script working. If you want to take a deeper look, all build issues are logged in serialice/qemu-0.15.x/config.log
References:
http://www.lua.org/faq.html#1.1