Wireshark-dev: Re: [Wireshark-dev] Lua linkage with CMake
From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Sat, 25 Aug 2012 12:00:15 +0200
On Fri, Aug 24, 2012 at 06:17:54PM -0400, Evan Huus wrote:
> I recently attempted to switch from autotools to cmake for building
> wireshark, but for some reason cmake won't link liblua properly:
> 
> lib/libwireshark.so: undefined reference to `lua_tonumber'
> lib/libwireshark.so: undefined reference to `lua_call'
> lib/libwireshark.so: undefined reference to `lua_pcall'
> lib/libwireshark.so: undefined reference to `luaL_loadfile'
> lib/libwireshark.so: undefined reference to `luaL_register'
> 
> If I compile with VERBOSE=1, the failing gcc command is:
> 
> /usr/bin/gcc   -O2 -g -Wall -W -Wextra -Wendif-labels -Wpointer-arith
> -Warray-bounds -Wcast-align -Wformat-security -fexcess-precision=fast
> -Wdeclaration-after-statement -Wno-pointer-sign -Wold-style-definition
>    -Wl,--as-needed CMakeFiles/dftest.dir/dftest.c.o
> CMakeFiles/dftest.dir/ui/util.c.o  -o dftest -rdynamic
> -L/home/eapache/Desktop/wireshark/ui/gtk
> -L/home/eapache/Desktop/wireshark/ui/qt
> -L/home/eapache/Desktop/wireshark/codecs
> -L/home/eapache/Desktop/wireshark/epan
> -L/home/eapache/Desktop/wireshark/wiretap
> -L/home/eapache/Desktop/wireshark/wsutil lib/libwireshark.so -lpcap
> -lcares -lkrb5 -llua5.2 -lGeoIP -lgcrypt -lgpg-error -lgnutls -lsmi
> -lz -lm lib/libwiretap.so -lgmodule-2.0 -lrt -lz lib/libwsutil.so
> -lglib-2.0 -Wl,-rpath,/home/eapache/Desktop/wireshark/ui/gtk:/home/eapache/Desktop/wireshark/ui/qt:/home/eapache/Desktop/wireshark/codecs:/home/eapache/Desktop/wireshark/epan:/home/eapache/Desktop/wireshark/wiretap:/home/eapache/Desktop/wireshark/wsutil:/home/eapache/Desktop/wireshark/lib:
> 
> The switch "-llua5.2" does exist in the above line, and is the correct
> switch, so I guess it's just not late enough in the list of libraries.
> Knowing nothing about cmake, I thought I'd ask here - where should I
> be looking to figure out what's gone wrong? Autotools builds (and
> links with liblua) correctly.

Can you try setting the environment variable LUA_DIR to the lua installation
(without /lib and /include suffixes) and then running cmake?
LUA_DIR=/path/to/lua52/topdir cmake <cmakeargs>

Btw, where is your lua2 stuff installed that the default search paths don't
pick it up? If autotools pick it up it looks like a bug to me.

Thanks
       Jörg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.