Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] Lua linkage with CMake

From: Evan Huus <eapache@xxxxxxxxx>
Date: Fri, 24 Aug 2012 18:17:54 -0400
Hi all,

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.

Thanks,
Evan