Compiling Wireshark using MS VS Express 2012 on Windows 7

Compiling Wireshark using MS VS Express 2012 on Windows 7

This is an article about compilation of Wireshark on Windows 7 (Ultimate SP1) and the issues I faced apart from standard documented procedure listed on Wireshark website.

A Summary about my development environment
Host OS:    Windows 7 Ultimate (SP1) 32bit version

Other Tools:  Python 2.7, Cygwin, Microsoft Visual Studio Express 2012 for Desktop and Microsoft Windows SDK for Windows 7, Tortoise SVN

Reference Guide for compiling wireshark
http://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.html
Pre-requisite Software requirements
  • Install ‘Microsoft Visual Studion Express 2012 for Desktop‘ from Microsoft website
  • Install ‘Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 (SP1)‘. I chose to opt out installation of .NET components due to space constraints.
  • Installation of Cygwin (I don’t remember if it was with default installation options or will full but recommend to install all of it)
  • Install Python 2.7 . I first installed version 3.4 but it did not go well with wireshark compilation.
  • Install Torotoise SVN

Compilation Steps

  • Download Wireshark Source
Download Wireshark source code into  C:/wireshark directory. The SVN repository is  http://anonsvn.wireshark.org/wireshark/trunk/’
  • Configure config.nmake
Uncomment ‘ MSVC_VARIANT=MSVC2012‘ from  config.nmake ( C:/wireshark/config.nmake). There are other parameters you can configure too. Please refer to original documentation in this regard..
  • Create Compilation environment

a.  Start ‘VS Express for Destop‘ and go to ‘Tools‘ -> ‘External Tools‘ and add following details in the ‘External Tools‘ Window:
Title                                       Wireshark Env
Command                              C:\Windows\System32\cmd.exe
Arguments                              /k “c:\Program Files\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat”
Initial Directory                       C:\wireshark 

b. Click on ‘Add‘ button to add it permanently. Now, this command will be visible in ‘Tools‘ menu as ‘Wireshark Env

c. Now click on ‘Tools‘ -> ‘Wireshark Env‘ to start ‘cmd.exe‘ with its compilation environment set.

d. For compilation, a file ‘win32.mak‘ is required, so set the following INCLUDE path in the cmd.exe.

set INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDKs\Windows\v7.0\include;
   
    
This should avoid getting the following error afterwards.

Makefile.nmake(10) : fatal error U1052: file ‘win32.mak’ not found
Stop.
  • Compilation
a.  Verify installed tools         > nmake -f Makefile.nmake verify_tools

If you get any errors in the output, please ensure you set the compilation environment correctly. The correct output is given below:


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

Checking for required applications:
        cl: /cygdrive/c/Program Files/Microsoft Visual Studio 11.0/VC/BIN/cl
        link: /cygdrive/c/Program Files/Microsoft Visual Studio 11.0/VC/BIN/link
        nmake: /cygdrive/c/Program Files/Microsoft Visual Studio 1.0/VC/BIN/nma

ke

        bash: /usr/bin/bash
        bison: /usr/bin/bison
        flex: /usr/bin/flex
        env: /usr/bin/env
        grep: /usr/bin/grep
        /usr/bin/find: /usr/bin/find
        peflags: /usr/bin/peflags
        perl: /usr/bin/perl
        C:\Python27\python.exe: /cygdrive/c/Python27/python.exe
        sed: /usr/bin/sed
        unzip: /usr/bin/unzip
        wget: /usr/bin/wget


b. Install the required libraries

  > nmake -f Makefile.nmake setup

c. Cleanup the sources

   > nmake -f Makefile.nmake distclean

d. Build Wireshark

   > nmake -f Makefile.nmake all

Compilation takes few minutes and if it is successful, you should get wireshark exectuable file at ‘C:\wireshark\wireshark-gtk2‘. 

NOTE
a.   If you face any compilation error and make any correction in any file (configs, env etc), please ensure the ‘Cleanup the sources’ (point c) before building it again.

b.  If the compilation breaks in between due to linking errors (unresolved symbols), try to find one of those symbols in C:\wireshark directory.
There are some source files that are generated during compilation and the makefiles are written in a manner to create empty source files if they encounter any error. This might be helpful in continuing the compilation to subsequent files but it ultimately breaks during linking process and hence finding the actual cause of linking error complex.
If that symbol happens to be in a file for which an empty source file is present, make sure to delete that file manually otherwise a new file will not be generated.

d. Run Wireshark

    > C:\wireshark\wireshark-gtk2\wireshark.exe







I followed the "Win32/64: Step-by-Step Guide" But i get stuck at the point where i have to call "nmake" with "verify_tools"

It gives me following result when i run it:

"C:\wireshark>nmake -f makefile.nmake verify_tools"
Microsoft (R) Program Maintenance Utility Version 11.00.60610.1
Copyright (C) Microsoft Corporation.  All rights reserved.
><  ,tools/win32-setup.sh: line 32: exec: --: invalid option  exec:
usage: exec [-cl] [-a name] [command
[arguments ...]] [redirection ...]
><  ,tools/win32-setup.sh: line 32:
exec: --: invalid option  exec: usage:
exec [-cl] [-a name] [command
[arguments ...]] [redirection ...]
NMAKE : fatal error U1077:
'C:\Cygwin\bin\bash.EXE' : return code
'0x2'  Stop.

I inserted a "printf" into the "win32-setup.sh" to see the content of "WIN_SETUP"

win32-setup.sh looks like this then:

export DOWNLOAD_TAG="2014-04-16"
export WIRESHARK_TARGET_PLATFORM="win32"
WIN_SETUP=`echo $0 | sed -e s/win32/win/`
printf ">%s<\n", $WIN_SETUP
exec $WIN_SETUP $@

Up in the result you can see "><". That means the "WIN_SETUP" is quite empty. Don't know exactly if that is the problem or why is empty.

I don't know anymore how to fix that after hours of searching and investigating.

I would really appreciate if someone could help me with that issue.

Thanks in advance.

Gerald

asked 12 May, 13:51

Sessler%20Gerald's gravatar image

Sessler Gerald
11113
accept rate: 0%

edited 14 May, 02:36

grahamb's gravatar image

grahamb ♦
10.8k224143

First:

Given that you're running om WIN64, I would have expected that win64-setup.sh would have been called, not win32-setup.sh.

Are you using the 64-bit compiler (or the 32 bit) ?

Are you explicitly trying to build a win32 version by doing:

"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd"  /Release /x86  ?

Please try doing the following (instead of the call to setenv). which I think should automatically set things up to do a win64 (or win32) build (depending upon which compiler you are using).

64 bit compiler:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\Vcvarsall.bat x64"

If you are actually using the 32-bit compiler then replace x64 by x86.

(I'll spend a bit more time tomorrow looking at the instructions in the Developer's Guide to see if any changes are needed...)


If you still get the same error, then please do the following (presumably now in the win64-setup.sh)

Please add the following before the WIN_SETUP=... and let us know the output.

echo $PATH
sed --version
printf ">%s<" "$0"

(Note that a ',' should not be put between the format and the arg(s) in the printf).


(12 May, 19:16) Bill Meier ♦♦

First of all... Thanks a lot for spending your time on my case.

I had set the compiler to x86 because at the beginning I tried with x64 and didn't work. So i thought it maybe works with x86 but i was wrong.

The path you mentioned => "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" doesn't exist on my machine.

As you recommended, I called again "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\Vcvarsall.bat x64"

Now gets called the "win64-setup.sh". I inserted the code you gave me into the "win64-setup.sh" file.

Now it shows an additional error: Can't find Qt. .....

Below i copied you the command line output:

C:\wireshark>nmake -f makefile.nmake verify_tools

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

/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow :/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/BIN/amd64:/cygdrive/c/Windows/Microsoft.NET/F ramework64/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework64/v3.5:/cygdrive/c/Program Files (x86)/Micro soft Visual Studio 11.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE :/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/Tools:/cygdrive/c/Program Files (x86)/HT ML Help Workshop:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Team Tools/Performance Tools/x64 :/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Team Tools/Performance Tools:/cygdrive/c/Program Files (x86)/Windows Kits/8.0/bin/x64:/cygdrive/c/Program Files (x86)/Windows Kits/8.0/bin/x86:/cygdrive/c/Pro gram Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0 Tools/x64:/cygdrive/c/Program Files (x86)/Microsof t SDKs/Windows/v7.0A/Bin/x64:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0 Tools:

(13 May, 13:53) Sessler Gerald

/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Bin:/cygdrive/c/Program Files (x86)/Microsoft Vis ual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/cygdrive/c/Program Files (x86)/Microsoft SD Ks/F#/3.0/Framework/v4.0:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VSTSDB/Deploy:/cygdrive/ c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visua l Studio 11.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/Tools:/cygdrive/c/Wi ndows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML Help Workshop:/cyg drive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Team Tools/Performance Tools:/cygdrive/c/Program File s (x86)/Windows Kits/8.0/bin/x86:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0 To ols:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Bin:/cygdrive/c/Python34:/cygdrive/c/Python34 /Scripts:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Program Files (x86)/Intel /iCLS Client:/cygdrive/c/Program Files/Intel/iCLS Client:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cyg drive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/In tel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Compo nents/IPT:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2 .0/bin/x86:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x64:/cygdrive/c/Program Files/Lucidlogix T echnologies/VIRTU MVP:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files (x8 6)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0:

(13 May, 13:59) Sessler Gerald

/cygdrive/c/Program Files (x86)/Windows Kits/8.0/Windows Performan ce Toolkit:/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/cygdrive/c/Program Files (x86)/Visua lSVN/bin:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive /c/Users/The Sky/AppData/Local/Android/android-sdk/tools:/cygdrive/c/Program Files/Microsoft SQL Server/110/DT S/Binn:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/Tools/Binn:/cygdrive/c/Program Files (x86)/Mic rosoft SQL Server/110/Tools/Binn/ManagementStudio:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0 /Common7/IDE/PrivateAssemblies:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/cygdrive/c/W indows/System32/WindowsPowerShell/v1.0:/usr/bin:/cygdrive/c/Program Files/TortoiseGit/bin:/cygdrive/c/Program Files (x86)/Microchip/xc32/v1.21/bin:/cygdrive/c/Program Files/smartmontools/bin:/cygdrive/c/cygwin/bin:/cygdr ive/c/cygwin/bin:/cygdrive/c/Wireshark-win64-libs/gtk2/bin:/cygdrive/c/bin:/cygdrive/c/Wireshark-win64-libs/zl ib125

tools/win64-setup.sh<

tools/win64-setup.sh: line 34: exec: --: invalid option exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...] Can't find Qt. This will become a problem at some point.

// I deleted here the second "Echo $Path" result => to much text

tools/win64-setup.sh<

tools/win64-setup.sh: line 34: exec: --: invalid option exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...] NMAKE : fatal error U1077: 'C:\Cygwin\bin\bash.EXE' : return code '0x2' Stop.

C:\wireshark>

.

Seems it gets called 2 times, so i deleted the second result of "Echo $Path" to prevent posting redundant text because it is quite long.

Hope you can find out something. Otherwise I'll have to try it on a different machine praying to have more luck there.

Thanks a lot for your effort.

Gerald

(13 May, 14:06) Sessler Gerald


One Answer:
0

OK, I've take the path you posted, split it at the separator ":", and then sorted it. There may be the odd extra space due to formatting, cut and paste etc, but I think it shows you have an extraordinarily complicated path IMHO, with a fair amount of dupes:

/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin
/cygdrive/c/Program Files (x86)/HTML Help Workshop
/cygdrive/c/Program Files (x86)/HTML Help Workshop
/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL
/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT
/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2 .0/bin/x86
/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x64
/cygdrive/c/Program Files (x86)/Intel/iCLS Client
/cygdrive/c/Program Files (x86)/Microchip/xc32/v1.21/bin
/cygdrive/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0
/cygdrive/c/Program Files (x86)/Microsoft SD Ks/F#/3.0/Framework/v4.0
/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Bin
/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Bin
/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Bin/x64
/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0 To ols
/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0 Tools
/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v8.0A/bin/NETFX 4.0 Tools/x64
/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn
/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/Tools/Binn
/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/Tools/Binn/ManagementStudio
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0 /Common7/IDE/PrivateAssemblies
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/Tools
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/Tools
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Team Tools/Performance Tools
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Team Tools/Performance Tools
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/Team Tools/Performance Tools/x64
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/BIN
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/BIN/amd64
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/VCPackages
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/VCPackages
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 11.0/VSTSDB/Deploy
/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/cygdrive/c/Program Files (x86)/VisualSVN/bin
/cygdrive/c/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit
/cygdrive/c/Program Files (x86)/Windows Kits/8.0/bin/x64
/cygdrive/c/Program Files (x86)/Windows Kits/8.0/bin/x86
/cygdrive/c/Program Files (x86)/Windows Kits/8.0/bin/x86
/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Compo nents/IPT
/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL
/cygdrive/c/Program Files/Intel/iCLS Client
/cygdrive/c/Program Files/Lucidlogix Technologies/VIRTU MVP
/cygdrive/c/Program Files/Microsoft SQL Server/110/DT S/Binn
/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn
/cygdrive/c/Program Files/Microsoft/Web Platform Installer
/cygdrive/c/Program Files/TortoiseGit/bin
/cygdrive/c/Program Files/TortoiseSVN/bin
/cygdrive/c/Program Files/smartmontools/bin
/cygdrive/c/Python34
/cygdrive/c/Python34/Scripts
/cygdrive/c/Users/The Sky/AppData/Local/Android/android-sdk/tools
/cygdrive/c/Windows
/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5
/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319
/cygdrive/c/Windows/Microsoft.NET/Framework64/v3.5
/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319
/cygdrive/c/Windows/System32/Wbem
/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
/cygdrive/c/Windows/system32
/cygdrive/c/Wireshark-win64-libs/gtk2/bin
/cygdrive/c/Wireshark-win64-libs/zlib125
/cygdrive/c/bin
/cygdrive/c/cygwin/bin
/cygdrive/c/cygwin/bin
/usr/bin

Can you please open a Visual Studio Command Prompt (found in the Start Menu under Visual Studio), x64 or x86 it doesn't really matter, and then execute `echo %PATH% > %TEMP%\mypath.txt, and then post the contents of that file as a comment.

link

answered 14 May, 02:27

grahamb's gravatar image

grahamb ♦
10.8k224143
accept rate: 20%


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值