This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

How do you cross compile wireshark on Linux for Windows?

0

Someone else recently asked this question, and the answer was to file a bug. Unfortunately, no link to the bug was posted, so here I am with the same question. Here is the basic info:

./configure --build=x86-pc-linux-gnu --host=i586-mingw32msvc

[...]

 checking for connect in -lsocket... no
 configure: error: Function 'socket' not found.

config.log:

 configure:24681: checking for connect in -lsocket
 configure:24706: i586-mingw32msvc-gcc -o conftest.exe -g -O2 -Wall -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wpointer-arith -Wno-pointer-sign -Wcast-align -Wformat-security -Wold-style-definition -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -D_FORTIFY_SOURCE=2 -D_U_="__attribute__((unused))"  -I/usr/local/include  -Wl,--as-needed -L/usr/local/lib conftest.c -lsocket   >&5
 i586-mingw32msvc-gcc: unrecognized option '-pthread'
 conftest.c: In function 'main':
 conftest.c:37: warning: old-style function definition
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lsocket
 collect2: ld returned 1 exit status

Actually I'm only doing this because I'm trying to cross compile a dissector and I'm getting pthread errors there. It looks like glib is trying to use pthreads when it shouldn't:

 make  all-recursive
 make[1]: Entering directory `/Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin'
 Making all in routing
 make[2]: Entering directory `/Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin/routing'
 depbase=`echo add-peer.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
    /bin/bash ../libtool --tag=CXX   --mode=compile i586-mingw32msvc-g++ -DHAVE_CONFIG_H -I. -I..    -DENABLE_BINDIST -O2 -Wuninitialized  -g2 -ggdb -Wparentheses -Wswitch-enum -Wimplicit -Wformat -Wundef -Wshadow -Wall -W -Wreturn-type -Wunused -Wcast-qual -Wwrite-strings -Wconversion -Wsign-compare -Wredundant-decls -Wsign-promo -isystem "/home/CF-CAL/andrew.knutsen/src/wireshark-1.8.11"  -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -iquote "/Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin" -fvisibility=hidden -g -O2 -MT add-peer.lo -MD -MP -MF $depbase.Tpo -c -o add-peer.lo add-peer.cpp &&\
    mv -f $depbase.Tpo $depbase.Plo
 libtool: compile:  i586-mingw32msvc-g++ -DHAVE_CONFIG_H -I. -I.. -DENABLE_BINDIST -O2 -Wuninitialized -g2 -ggdb -Wparentheses -Wswitch-enum -Wimplicit -Wformat -Wundef -Wshadow -Wall -W -Wreturn-type -Wunused -Wcast-qual -Wwrite-strings -Wconversion -Wsign-compare -Wredundant-decls -Wsign-promo -isystem /home/CF-CAL/andrew.knutsen/src/wireshark-1.8.11 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -iquote /Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin -fvisibility=hidden -g -O2 -MT add-peer.lo -MD -MP -MF .deps/add-peer.Tpo -c add-peer.cpp  -DDLL_EXPORT -DPIC -o .libs/add-peer.o
 In file included from /usr/include/glib-2.0/glib.h:108,
                 from /home/CF-CAL/andrew.knutsen/src/wireshark-1.8.11/wiretap/wtap.h:30,
                 from /home/CF-CAL/andrew.knutsen/src/wireshark-1.8.11/epan/packet.h:28,
                 from /Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin/util/base-registration.hpp:9,
                 from registration-block.hpp:6,
                 from add-peer.cpp:1:
/usr/include/glib-2.0/glib/deprecated/gthread.h:123:21: error: pthread.h: No such file or directory
 In file included from /usr/include/glib-2.0/glib.h:108,
                 from /home/CF-CAL/andrew.knutsen/src/wireshark-1.8.11/wiretap/wtap.h:30,
                 from /home/CF-CAL/andrew.knutsen/src/wireshark-1.8.11/epan/packet.h:28,
                 from /Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin/util/base-registration.hpp:9,
                 from registration-block.hpp:6,
                 from add-peer.cpp:1:
/usr/include/glib-2.0/glib/deprecated/gthread.h:133: error: 'pthread_mutex_t' does not name a type
/usr/include/glib-2.0/glib/deprecated/gthread.h:162: error: 'pthread_t' does not name a type
 make[2]: *** [add-peer.lo] Error 1
 make[2]: Leaving directory `/Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin/routing'
 make[1]: *** [all-recursive] Error 1
 make[1]: Leaving directory `/Workspaces/andrew.knutsen_ubuntu1204_SDE/tools/ADN/WiresharkPlugin'
 make: *** [all] Error 2

asked 21 Jan '14, 17:56

Andrew%20Knutsen's gravatar image

Andrew Knutsen
11112
accept rate: 0%

edited 21 Jan '14, 18:56

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196


One Answer:

1

We don't support cross-compiling for Windows on any flavor of UN*X.

You could file an enhancement request at the Wireshark Bugzilla, but supporting cross-compiling for Windows would probably be a lot more work than supporting cross-compiling for some other UN*X (which is what the other person was trying to do), and I don't know whether any Wireshark developer has a setup to do that sort of cross-compiling, so the enhancement probably won't be implemented soon unless somebody (core developer or not) who is familiar with that sort of cross-development, and has an environment on which to try to make it work, does so.

answered 21 Jan '14, 19:56

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%