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

How to cross compile Wireshark x64 on an x86 Windows machine

0

I am using rev 37663 of Wireshark (1.7.0) and VS 2008 on Windows XP x86 and I would like to compile a 64-bit version of Wireshark. I have followed all the instructions detailed in http://wiki.wireshark.org/Development/Win64

Here's what I've done:

  • prepared cmd.exe by running:

    "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64
  • I've also tried running this command as well, with the same result:

    "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"

  • I've downloaded vcredist_x64.exe and put it into:

    C:\wireshark-win64-libs

  • I've modified a line in config.nmake to this:

    WIRESHARK_TARGET_PLATFORM=win64

I've run the following commands:

nmake -f Makefile.nmake verify_tools
nmake -f Makefile.nmake setup
nmake -f Makefile.nmake distclean
nmake -f Makefile.nmake all

which all succeed until the last command. Here is the output of the last command:

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

Verifying library package files …

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved.

Wireshark is ready to build. sed -e s/@[email protected]/1.7.0"-HONE-TEST-x64-1"/ -e "s/@[email protected]/#define HAVE_C_ARES 1/" -e "s/@[email protected]//" -e "s/@[email protected]//" -e "s/@HAVE_KF [email protected]//" -e "s/@[email protected]//" -e "s/@[email protected]/#define HAVE_LIBZ 1/" -e "s/@H [email protected]/#define HAVE_LIBPCAP 1/" -e "s/@[email protected]/#define HAV E_PCAP_FINDALLDEVS 1/" -e "s/@[email protected]/#define HAVE_PCAP _DATALINK_NAME_TO_VAL 1/" -e "s/@[email protected]/#define HAVE_P CAP_DATALINK_VAL_TO_NAME 1/" -e "s/@[email protected]/#def ine HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1/" -e "s/@[email protected]//" - e "s/@[email protected]/#define HAVE_REMOTE 1/" -e "s/@[email protected]/#define HAV E_PCAP_REMOTE 1/" -e "s/@[email protected]/#define HAVE_PCAP_OPEN 1/" -e "s/@HAV [email protected]/#define HAVE_PCAP_OPEN_DEAD 1/" -e "s/@HAVE_PCAP_LIST_DATALIN [email protected]/#define HAVE_PCAP_LIST_DATALINKS 1/" -e "s/@[email protected]/#defi ne HAVE_PCAP_FREE_DATALINKS 1/" -e "s/@[email protected]/#define HAVE_PCA P_SET_DATALINK 1/" -e "s/@[email protected]/#define HAVE_PCAP_SETSAMPLING 1/" -e "s/@[email protected]/#define HAVE_BPF_IMAGE 1/" -e "s/@HAVE_LIBWIRESHARK [email protected]/#define HAVE_LIBWIRESHARKDLL 1/" -e "s/@[email protected]/#define HAVE_LIBGN UTLS 1/" -e "s/@[email protected]/#define HAVE_LIBGCRYPT 1/" -e "s/@[email protected]/#d efine HAVE_LUA 1/" -e "s/@[email protected]/#define HAVE_LUA_5_1 1/" -e "s/@HAVE_P [email protected]//" -e "s/@[email protected]//" -e "s/@[email protected]//" -e "s/@HAVE_LIBPOR [email protected]/#define HAVE_LIBPORTAUDIO 1/" -e "s/@[email protected]//" -e "s/@HAVE_S [email protected]//" -e "s/@[email protected]/#define HAVE_GEOIP 1/" -e "s/@[email protected]/#define INET6 1 /" -e "s/@[email protected]/#define HAVE_NTDDNDIS_H 1/" -e "s/@MAIN_MENU_USE_UI [email protected]//" -e "s/@[email protected]//" -e "s/@[email protected]/#define HAVE_HONE 1/" -e "s/@[email protected]//" -e "s/@[email protected]//" -e "s /@[email protected]//" < config.h.win32 > config.h cd tools "C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe" / -f Makefile.nmake

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved.

    cd lemon
    ..\native-nmake &quot;C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nma

ke.exe" / -f Makefile.nmake Setting environment for using Microsoft Visual Studio 2008 x86 tools.

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved.

    cl -WX -D_U_=&quot;&quot; /Zi /W3 /MD /DWIN32_LEAN_AND_MEAN /DMSC_VER_REQUIRED=150

0 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /MP /GS lemon.c Microsoft (R) C/C++ Optimizing Compiler Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

lemon.c Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved.

/out:lemon.exe /debug lemon.obj MSVCRT.lib(chkstk.obj) : fatal error LNK1112: module machine type 'X86' conflict s with target machine type 'x64' NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \x86_amd64\cl.EXE"' : return code '0x2' Stop. NMAKE : fatal error U1077: '..\native-nmake.CMD' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \nmake.exe"' : return code '0x2' Stop.

What am I missing? -Russ

asked 13 Feb ‘12, 18:47

ruslanad's gravatar image

ruslanad
1112
accept rate: 0%

edited 13 Feb ‘12, 19:56

helloworld's gravatar image

helloworld
3.1k42041


One Answer:

1

Somehow you have an x86 object (chkstk.obj) module that obviously won't link with amd64 code.

There are some lines in the output that intrigues me:

        cd lemon
        ..\native-nmake "C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe" -f Makefile.nmake
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

Why is the environment being set for x86? chkstk.obj is a Visual Studio/SDK object file and is provided in both x86 and amd64 versions. I suspect that the library search path is being set to x86 by the last line I've shown above.

I can't see what would be causing this looking at Makefile.nmake in the lemon directory. Have you made any source modifications at all?

answered 14 Feb '12, 01:07

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

The environment is being set back to x86 in native-nmake.cmd by calling vcvarsall.bat without any arguments. This is in fact the correct behavior, because when I changed that line in native-nmake.cmd to set the environment for cross-compiling, the build process failed later on. It turns out that the lemon executable gets executed later in the build process. This means that it does indeed need to be compiled in the x86 environment. The problem is that NMAKE thinks that it should be compiling 64-bit code and fails because we are (correctly) trying to generate 32-bit code in this one instance.

(14 Feb '12, 12:19) ruslanad