This wiki has been migrated to https://gitlab.com/wireshark/wireshark/-/wikis/home and is now deprecated. Please use that site instead.
Differences between revisions 1 and 8 (spanning 7 versions)
Revision 1 as of 2005-02-02 21:25:55
Size: 1346
Editor: UlfLamping
Comment: first content from a Mail from Laurent Rabret
Revision 8 as of 2005-03-14 21:20:13
Size: 5985
Editor: outgoing
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= MSVC7 = = Building Ethereal On Windows =
Line 3: Line 3:
The mainline to compile Ethereal under Windows is using Microsoft Visual Studio Version 6. This page describes, how Ethereal can be compiled with recent Microsoft compilers (Version 7 and higher) like Visual Studio 2k3 or the .NET Framework SDK.
Line 5: Line 5:
Here are some tips to compile Ethereal under newer compiler versions: '''The main line to compile Ethereal under Windows is still using Microsoft Visual Studio Version 6.'''
Line 7: Line 7:
to qoute a mail from Laurent Rabret (see http://www.ethereal.com/lists/ethereal-dev/200501/msg00636.html):
---------------------------------
To compile with the .NET SDK, you'll have to install the platform SDK
(available for free).
One of the reason for this is that the myriad of [http://anonsvn.ethereal.com/ethereal-win32-libs/tags/ 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:
Line 12: Line 9:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/  1. Unfortunately, it is believed by many that the Microsoft Visual Studio 2k3 EULA explicitly forbids linking with GPL'ed programs. This belief is probably due to an improper interpretation of the [http://msdn.microsoft.com/visualc/vctoolkit2003/eula.aspx Visual Studio 2k3 Toolkit EULA], which places redistribution restrictions only on SOURCE CODE SAMPLES which accompany the toolkit.
Line 14: Line 11:
You may encounter linking problems caused by "bad" parameters in config.nmake. I
never sent a patch to fix this because I'm not sure whether or not it
impacts VS6 compilation.
 1. Other maintainers believe that the GPL itself forbids using Visual Studio 2k3, 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 [http://www.gnu.org/licenses/gpl-faq.html#WindowsRuntimeAndGPL GPL FAQ] explicitly addresses this issue.

So due to this, the build process under newer versions of the Microsoft build environment does not work "out of the box". However, with a little work it is not only possible to build Ethereal under Visual Studio 2k3, but also under the combination of the freely available [http://www.microsoft.com/downloads/details.aspx?FamilyID=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en .NET Framework SDK] and the [http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ Platform SDK].

== Prerequisites ==

 * [http://www.microsoft.com/downloads/details.aspx?FamilyID=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en .NET Framework SDK] command-line compiler, linker, ...
 * [http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ Platform SDK] nmake, header files, ... (you will need a Microsoft Internet Explorer 5.0 or later to download this)
 * [http://www.cygwin.com Flex, bison and python, preferably from Cygwin]
 * [http://www.zlib.net Zlib 1.2.2 source]

== Setup ==

If you intend to build from the free SDK components as opposed to Visual Studio 7, you will need to combine the two path/environment scripts. The way I did this was to edit '''C:\Program File\Microsoft SDK\SetEnv.Bat''' and append a {{{call "C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat"}}} to the end.

Then you can add a {{{call "C:\Program Files\Microsoft SDK\SetEnv.Bat"}}} to your cygwin.bat startup script. Or, if you are just using VS7, add {{{call "c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"}}} to cygwin.bat.

Make sure all SDK/Toolkit paths precede your cygwin paths. In particular, {{{which link}}} from within cygwin should give you the SDK version.

At this point you can run {{{nmake -f Makefile.nmake setup}}} from within the ethereal src dir. Once it downloads all the required libs, you should download zlib 1.2.2 and compile it
by running {{{nmake -f win32/Makefile.msc}}}. If you are using the free SDK toolkits, you will have to change the {{{AR=lib}}} line to {{{AR=link /lib}}}. Note that building zlib this way from source is required, even though binaries is provided. This seems to be due to some incompatibility with {{{MSVCR71.DLL}}}.

Once the build is complete, run
{{{
cp zdll* /cygdrive/c/ethereal-win32-libs/zlib122-dll/lib
cp zlib1.dll /cygdrive/c/ethereal-win32-libs/zlib122-dll/
}}}

If you are building under the SDK's, you will need to compile setargv.obj:
{{{
cd "/cygdrive/c/Program Files/Microsoft DSK/src/crt"
cl.exe /c /I. /D_CRTBLD setargv.c
mv setargv.obj ../../Lib
}}}

== Hacking around compilation errors ==

At this point if you attempt to build, things may go smoothly for a while, but eventually you'll run into errors about the nonexistence of unistd.h. The windows equivalent to this header is io.h. Either go through all the files that include unistd.h and change it to io.h, or do the following:

{{{
cat > /cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ .NET\ 2003/Vc7/include/unistd.h << EOF
#include <io.h>
EOF
}}}

You will most likely also run into problems with undefined symbols for errno, mb_curr_max and pctype. This can be solved by adding the following lines to the following files:

'''plugins/asn1/packet-asn1.c''':
{{{
int __mb_cur_max;
const unsigned short* _pctype;
int errno;
}}}

'''plugins/mate/mate_plugin.c''':
{{{
int errno;
}}}

'''plugins/mgcp/packet-mgcp.c''':
{{{
int __mb_cur_max;
const unsigned short* _pctype;
}}}


You may also encounter linking problems caused by "bad" parameters in config.nmake.
Line 18: Line 80:
1) LOCAL_CFLAGS=/Zi /W3 by LOCAL_CFLAGS= /Zi /DWIN32 /W3
2) LOCAL_LDFLAGS=/DEBUG by LOCAL_LDFLAGS=/DEBUG /DEFAULTLIB:msvcrt
/NODEFAULTLIB:libc
 * {{{LOCAL_CFLAGS=/Zi /W3}}} '''with''' {{{LOCAL_CFLAGS= /Zi /DWIN32 /W3}}}
 * {{{LOCAL_LDFLAGS=/DEBUG}}} '''with''' {{{LOCAL_LDFLAGS=/DEBUG /DEFAULTLIB:msvcrt /NODEFAULTLIB:libc}}}
Line 24: Line 85:
LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)  * {{{LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)}}}
Line 26: Line 87:
LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386
...I know, that's not very clean ;-)
 * {{{LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386}}}
Line 29: Line 89:
This was not required by my build under the SDK, but others have reported needing it.
Line 30: Line 91:
At last, don't forget to include a line such this: == Building ==
Line 32: Line 93:
File "c:\program files\Microsoft Visual Studio .NET
2003\Common7\IDE\msvcr71.dll"
The ideal way to build is to create an installer. Add the following to '''packaging/nsis/ethereal.nsi''':
Line 35: Line 95:
... in your ethereal.nsi script (if you want to create an installer) {{{
File "c:\program files\Microsoft Visual Studio .NET 2003\Common7\IDE\msvcr71.dll"
}}}

Then run {{{nmake -f Makefile.nmake packaging}}}

This will build an ethereal-setup executable that will install all the libs you need to run it.
Line 37: Line 104:

This wiki entry was based upon [http://thread.gmane.org/gmane.network.ethereal.devel/12491 this mailinglist thread].

Building Ethereal On Windows

This page describes, how Ethereal can be compiled with recent Microsoft compilers (Version 7 and higher) like Visual Studio 2k3 or the .NET Framework SDK.

The main line to compile Ethereal under Windows is still using Microsoft Visual Studio Version 6.

One of the reason for this is that the myriad of [http://anonsvn.ethereal.com/ethereal-win32-libs/tags/ 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:

  1. Unfortunately, it is believed by many that the Microsoft Visual Studio 2k3 EULA explicitly forbids linking with GPL'ed programs. This belief is probably due to an improper interpretation of the [http://msdn.microsoft.com/visualc/vctoolkit2003/eula.aspx Visual Studio 2k3 Toolkit EULA], which places redistribution restrictions only on SOURCE CODE SAMPLES which accompany the toolkit.

  2. Other maintainers believe that the GPL itself forbids using Visual Studio 2k3, 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 [http://www.gnu.org/licenses/gpl-faq.html#WindowsRuntimeAndGPL GPL FAQ] explicitly addresses this issue.

So due to this, the build process under newer versions of the Microsoft build environment does not work "out of the box". However, with a little work it is not only possible to build Ethereal under Visual Studio 2k3, but also under the combination of the freely available [http://www.microsoft.com/downloads/details.aspx?FamilyID=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=en .NET Framework SDK] and the [http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ Platform SDK].

Prerequisites

Setup

If you intend to build from the free SDK components as opposed to Visual Studio 7, you will need to combine the two path/environment scripts. The way I did this was to edit C:\Program File\Microsoft SDK\SetEnv.Bat and append a call "C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat" to the end.

Then you can add a call "C:\Program Files\Microsoft SDK\SetEnv.Bat" to your cygwin.bat startup script. Or, if you are just using VS7, add call "c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat" to cygwin.bat.

Make sure all SDK/Toolkit paths precede your cygwin paths. In particular, which link from within cygwin should give you the SDK version.

At this point you can run nmake -f Makefile.nmake setup from within the ethereal src dir. Once it downloads all the required libs, you should download zlib 1.2.2 and compile it by running nmake -f win32/Makefile.msc. If you are using the free SDK toolkits, you will have to change the AR=lib line to AR=link /lib. Note that building zlib this way from source is required, even though binaries is provided. This seems to be due to some incompatibility with MSVCR71.DLL.

Once the build is complete, run

cp zdll* /cygdrive/c/ethereal-win32-libs/zlib122-dll/lib
cp zlib1.dll /cygdrive/c/ethereal-win32-libs/zlib122-dll/

If you are building under the SDK's, you will need to compile setargv.obj:

cd "/cygdrive/c/Program Files/Microsoft DSK/src/crt"
cl.exe /c /I. /D_CRTBLD setargv.c
mv setargv.obj ../../Lib

Hacking around compilation errors

At this point if you attempt to build, things may go smoothly for a while, but eventually you'll run into errors about the nonexistence of unistd.h. The windows equivalent to this header is io.h. Either go through all the files that include unistd.h and change it to io.h, or do the following:

cat > /cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ .NET\ 2003/Vc7/include/unistd.h << EOF
#include <io.h>
EOF

You will most likely also run into problems with undefined symbols for errno, mb_curr_max and pctype. This can be solved by adding the following lines to the following files:

plugins/asn1/packet-asn1.c:

int __mb_cur_max;
const unsigned short* _pctype;
int errno;

plugins/mate/mate_plugin.c:

int errno;

plugins/mgcp/packet-mgcp.c:

int __mb_cur_max;
const unsigned short* _pctype;

You may also encounter linking problems caused by "bad" parameters in config.nmake.

I replaced:

  • LOCAL_CFLAGS=/Zi /W3 with LOCAL_CFLAGS= /Zi /DWIN32 /W3

  • LOCAL_LDFLAGS=/DEBUG with LOCAL_LDFLAGS=/DEBUG /DEFAULTLIB:msvcrt /NODEFAULTLIB:libc

While compiling plugins, you might also encounter problems. For these plugins, in the Makefile.nmake file change

  • LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)

by

  • LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386

This was not required by my build under the SDK, but others have reported needing it.

Building

The ideal way to build is to create an installer. Add the following to packaging/nsis/ethereal.nsi:

File "c:\program files\Microsoft Visual Studio .NET 2003\Common7\IDE\msvcr71.dll"

Then run nmake -f Makefile.nmake packaging

This will build an ethereal-setup executable that will install all the libs you need to run it.


This wiki entry was based upon [http://thread.gmane.org/gmane.network.ethereal.devel/12491 this mailinglist thread].

Development/MSVC7 (last edited 2020-03-20 21:59:16 by GuyHarris)