4.4. Microsoft compiler toolchain (Win32 native)
To compile Wireshark on Windows using the Microsoft C/C++
compiler, you'll need:
-
C compiler (cl.exe)
-
Linker (link.exe)
-
Make (nmake.exe)
-
C runtime headers and libraries (e.g. stdio.h,
msvcrt.lib)
-
Windows platform headers and libraries (e.g.
windows.h, WSock32.lib)
-
HTML help headers and libraries (htmlhelp.h,
htmlhelp.lib)
4.4.1. Toolchain Package Alternatives
The official Wireshark 1.0.x releases are compiled using Microsoft
Visual C++ 6.0. The 1.1.x development releases are compiled using
Microsoft Visual C++ 2008 SP1. Using the release compilers is recommended
for Wireshark development work. Visual C++ 2008 Express Edition SP1 may
be used for the development branch, but it cannot create PortableApps
or U3 packages.
However, you might already have a different Microsoft C
compiler installed. With the considerations listed below, it should
be possible to use it as well:
1no longer officially available,
might still be available through the MSDN
subscriptions
2as the Platform SDK is already
integrated in the package, you obviously don't need to
install it and don't even need to call a separate environment
setting batch file for the Platform SDK!
3vcredist_x86.exe (3MB free
download) is required to build Wireshark-setup.exe. The
version of vcredist_x86.exe MUST match the version for
your compiler.
4Wireshark-setup.exe cannot be
created with this package, as msvcr*.dll is not available or
not redistributable!
5MSDN remarks that the
corresponding .NET runtime is required. It's currently
unclear if the runtime needs to be installed for the C
compiler to work - or is this only needed to compile / run
.NET programs?!?
6beta version, not suitable for
production use!
|
Note! |
The "Visual C++ Toolkit 2003" should NOT be used to
compile Wireshark!
|
4.4.2. Legal issues with MSVC > V6?
Please note: The following is not legal advice - ask
your preferred lawyer instead! It's the authors view, but
this view might be wrong!
The myriad of
Win32 support lib port projects all seem to believe
there are legal issues involved in using newer versions of
Visual Studio. This FUD essentially stems from two
misconceptions:
-
Unfortunately, it is believed by many that the
Microsoft Visual Studio 2003 EULA explicitly forbids
linking with GPL'ed programs. This belief is probably due
to an improper interpretation of the
Visual Studio 2003 Toolkit EULA, which places
redistribution restrictions only on SOURCE CODE SAMPLES
which accompany the toolkit.
-
Other maintainers believe that the GPL itself
forbids using Visual Studio 2003, since one of the
required support libraries (MSVCR71.DLL) does not ship
with the Windows operating system. This is also a
wrongful interpretation, and the
GPL FAQ explicitly addresses this issue.
Similar applies to Visual Studio 2005 and
alike.
So in effect it should be perfectly legal to compile
Wireshark and distribute / run it if it was compiled with any
MSVC version > V6!
4.4.3. cl.exe (C Compiler)
The following table gives an overview of the possible
Microsoft toolchain variants and their specific C compiler
versions "ordered by release date":
After correct installation of the toolchain, typing
at the command line prompt (cmd.exe):
>
cl
should result in something like:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption...
However, the version string may vary.
nmake is part of the toolchain packages described
above.
Instead of using the workspace (.dsw) and projects
(.dsp) files, the traditional nmake makefiles are used. This
has one main reason: it makes it much easier to maintain
changes simultaneously with the GCC toolchain makefile.am files
as both file formats are similar. However, as no Visual
Studio workspace/project files are available, this makes it
hard to use the Visual Studio IDE e.g. for using the
integrated debugging feature.
After correct installation, typing at the command
line prompt (cmd.exe):
>
nmake
should result in something like:
Microsoft (R) Program Maintenance Utility Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
However, the version string may vary.
Documentation on nmake can be found at
Microsoft MSDN
4.4.6. C-Runtime "Redistributable" files
Please note: The following is not legal advice - ask
your preferred lawyer instead! It's the authors view, but
this view might be wrong!
Depending on the Microsoft compiler version you use,
some binary files coming from Microsoft might
be required to be installed on Windows machine to run
Wireshark. On a developer machine, the compiler setup
installs these files so they are available - but they might
not be available on a user machine!
This is especially true for the C runtime DLL
(msvcr*.dll), which contains the implementation of ANSI and
alike functions, e.g.: fopen(), malloc(). The DLL is named
like: msvcr<version>.dll, an abbreviation for
"MicroSoft Visual C Runtime". For Wireshark to work, this DLL
must be available on the users machine.
MSVC6 was using msvcrt.dll, which is already available
on all recent windows systems - no need to redistribute
anything. Starting with MSVC7, it is necessary to ship the C
runtime DLL (msvcr<version>.dll) together with the
application installer somehow, as that DLL is possibly not
available on the target system.
|
Note! |
The files to redistribute must be mentioned in the
redist.txt file of the compiler package - otherwise it
can't be legally redistributed by third parties like
us!
|
The following MSDN links are recommended for the
interested reader:
4.4.6.1. msvcrt.dll - Version 6.0
Redistributables weren't an issue with MSVC 6, as any
realistic installer target system (>= Win95) already
contains the corresponding msvcrt.dll.
4.4.6.2. msvcr70.dll - Version 7.0 (2002)
"Visual Studio .NET (2002)" - comes with this dll and
it's mentioned in redist.txt.
".NET Framework SDK 1.0" doesn't even come with this
dll. XXX - Is this file available with the .NET 1.0
runtime (dotnetfx.exe) - so it could be shipped instead?!?
Do we want it that way?
4.4.6.3. msvcr71.dll - Version 7.1 (2003)
"Visual Studio .NET 2003" comes with this dll
and it's mentioned in redist.txt.
".NET Framework SDK 1.1" comes with this dll, but
it's NOT mentioned in redist.txt. XXX - Is this file
available with the .NET 1.1 runtime
(dotnetfx.exe) - so it could be shipped instead ?!? Do we
want it that way?
4.4.6.4. msvcr80.dll / vcredist_x86.exe - Version 8.0
(2005)
There are three redistribution methods that MSDN
mentions for MSVC 8 (see: "
Choosing a Deployment Method"):
-
"Redistributable Merge Modules" (kind of loadable
modules for building msi installers - not suitable for
Wireshark's NSIS based installer)
-
copy the folder content of Microsoft.VC80.CRT to
the target directory (e.g. "C:\program
files\Wireshark")
-
vcredist_x86.exe (needs to be executed on the
target machine - MSDN recommends this for the 2005
Express Editions)
To save installer size, MSVC2005 uses the
content of Microsoft.VC80.CRT (method 2 - this is the
smallest package). As MSVC2005EE and DOTNET20 doesn't
provide the folder "Microsoft.VC80.CRT" they use method 3.
You'll have to download a vcredist_x86.exe from Microsoft
that matches your compiler version. The best way to
determine this version is to open one of the generated
manifest files (e.g. wireshark.exe.manifest) and look for
the version of the Microsoft.VC80.CRT entry.
Please report to the developer mailing list, if you
find a different version number!
4.4.6.5. msvcr90.dll / vcredist_x86.exe - Version 9.0 (2008)
Please report to the developer mailing list, if you
find a different version number!
4.4.6.6. Version 10.0 (2010)?
As the corresponding C compiler is preliminary, it's
too early to say!
4.4.7. Windows (Platform) SDK
The Windows Platform SDK (PSDK) is a free (as in
beer) download and contains platform specific headers and
libraries (e.g. windows.h, WSock32.lib, ...). As new Windows
features evolve in time, updated PSDK's become available that
include new and updated API's.
When you purchase a commercial Visual Studio, it will
include a PSDK. The free (as in beer) downloadable C compiler
versions (VC++ 2005 Express, .NET Framework, ...) do not
contain a PSDK - you'll need to download a PSDK in order to
have the required C header files and libraries.
Older Versions of the Platform SDK should also work.
However, the command to set the environment settings will be
different, try search for SetEnv.* in the SDK
directory.
BTW: "Windows SDK" seems to be the new name of the
Platform SDK for Vista. The current SDK name is misleading:
"Microsoft� Windows� Software Development Kit for
Windows Vista™ and .NET Framework 3.0 Runtime
Components" - translated this means: the Windows SDK for
Windows Vista and Platforms (like WinXP) that have the .NET
3.0 runtime installed.
The HTML Help is used to create the User's and
Developer's Guide in .chm format and to show the User's Guide
as the Wireshark "Online Help".
Both features are currently optional, but might be
mandatory in future versions.
4.4.8.1. HTML Help Compiler (hhc.exe)
This compiler is used to generate a .chm file
from a bunch of HTML files - in our case to generate
the User's and Developer's Guide in .chm format.
The compiler is only available as the free (as in
beer) "HTML Help Workshop" download. If you want to compile
the guides yourself, you need to download and install this.
If you don't install it into the default directory, you may
also have a look at the HHC_DIR setting in the file
docbook/Makefile.
4.4.8.2. HTML Help Build Files (htmlhelp.c /
htmlhelp.lib)
The files htmlhelp.c and htmlhelp.lib are required to
be able to open .chm files from Wireshark - to show the
"online help".
Both files are part of the Platform SDK (standalone
PSDK or MSVC since 2002). If you still use MSVC 6, you
can get them from the "HTML Help Workshop" mentioned
above.
The related settings in config.nmake depend on the
MSVC variant you use:
-
MSVC 6: if the "HTML Help Workshop" is
installed, set HHC_DIR to its directory
-
> MSVC 6: set HHC_DIR to use it (the actual
value doesn't matter in this case)
Well, using a good debugger can save you a lot of
development time.
The debugger you use must match the C compiler
Wireshark was compiled with, otherwise the debugger will
simply fail or you will only see a lot of garbage.
4.4.9.1. Visual Studio integrated debugger
You can use the integrated debugger of Visual Studio
- only available in some of the toolchain packages.
However, setting up the environment is a bit tricky,
as the Win32 build process is using makefiles instead of
the .dsp/.dsw files usually used.
XXX - add instructions how to do it.
4.4.9.2. Debugging Tools for Windows
You could also use the Microsoft Debugging Tools for Windows toolkit,
which is a standalone GUI debugger. Although it's not that
comfortable compared to debugging with the Visual Studio
integrated debugger, it can be helpful if you have to debug
on a machine where an integrated debugger is not
available.
You can get it free of charge at:
https://www.microsoft.com/whdc/devtools/debugging/default.mspx (as
links to Microsoft pages change from time to time, search
for "Debugging Tools" at their page if this link should be
outdated).