4.4. GNU compiler toolchain (UNIX only)

4.4.1. gcc (GNU compiler collection)

The GCC C compiler is available for most of the UNIX-like platforms.

If GCC isn’t already installed or available as a package for your platform, you can get it at: http://gcc.gnu.org/.

After correct installation, typing at the bash command line prompt:

$ gcc --version

should result in something like

gcc (Ubuntu 4.9.1-16ubuntu6) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Your version string may vary, of course.

Wireshark’s build environment can be configured using CMake on Windows and either CMake or Autotools on Linux, macOS, and UNIX. CMake is designed to support out of tree builds. So much so, that in tree builds do not work properly in all cases. Along with being cross-platform, CMake supports many build tools and environments including traditional make, Ninja, and MSBuild. Our Buildbot runs CMake steps on Ubuntu, Win32, Win64, and macOS. In particular, the macOS and Windows packages are built using CMake.

Building with CMake typically includes creating a build directory and specifying a generator, aka a build tool. For example, to build Wireshark using Ninja in the directory wireshark-ninja you might run the following commands:

# Starting from your Wireshark source directory, create a build directory
# alongside it.
$ cd ..
$ mkdir wireshark-ninja
$ cd wireshark-ninja
# Assumes your source directory is named "wireshark".
$ cmake -G Ninja ../wireshark
$ ninja (or cmake --build .)

Using CMake on Windows is described further in Section 2.2.10, “Generate the build files”.

Along with specifying a generator with the -G flag you can set variables using the -D flag. Useful variables and generators include the following:

-DENABLE_CAP=OFF
Disable the POSIX capabilities check
-DCMAKE_BUILD_TYPE=Debug
Enable debugging symbols
-DENABLE_GTK3=ON
Enable GTK+ 3
-DENABLE_HTML_GUIDES=ON -DENABLE_PDF_GUIDES=ON
Build documentation
-DCMAKE_C_FLAGS=-Qunused-arguments
Make ccache and clang work together
-DPYTHON_EXECUTABLE=c:/Python27/python
Force the Python path. Useful on Windows since Cygwin’s /usrbin/python is a symlink.
-DENABLE_APPLICATION_BUNDLE=OFF
Disable building an application bundle (Wireshark.app) on macOS

You can list all build variables (with help) by running cmake -LH [options] ../<Name_of_WS_source_dir>. This lists the cache of build variables after the cmake run. To only view the current cache, add option -N.

After running cmake, you can always run make help to see a list of all possible make targets.

Note that CMake honors user umask for creating directories as of now. You should set the umask explicitly before running the install target.

CMake links:

The home page of the CMake project: http://www.cmake.org/

Official documentation: https://cmake.org/documentation/

About CMake in general and why KDE4 uses it: http://lwn.net/Articles/188693/

Introductory tutorial/presentation: http://ait.web.psi.ch/services/linux/hpc/hpc_user_cookbook/tools/cmake/docs/Cmake_VM_2007.pdf

Introductory article in the Linux Journal: http://www.linuxjournal.com/node/6700/print

Useful variables: http://www.cmake.org/Wiki/CMake_Useful_Variables

Frequently Asked Questions: http://www.cmake.org/Wiki/CMake_FAQ

4.4.2. gdb (GNU project debugger)

GDB is the debugger for the GCC compiler. It is available for many (if not all) UNIX-like platforms.

If you don’t like debugging using the command line there are some GUI frontends for it available, most notably GNU DDD.

If gdb isn’t already installed or available as a package for your platform, you can get it at: http://www.gnu.org/software/gdb/gdb.html.

After correct installation:

$ gdb --version

should result in something like:

GNU gdb (Ubuntu 7.8-1ubuntu4) 7.8.0.20141001-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".

Your version string may vary, of course.

4.4.3. ddd (GNU Data Display Debugger)

The GNU Data Display Debugger is a good GUI frontend for GDB (and a lot of other command line debuggers), so you have to install GDB first. It is available for many UNIX-like platforms.

If GNU DDD isn’t already installed or available as a package for your platform, you can get it at: http://www.gnu.org/software/ddd/.

4.4.4. make (GNU Make)

[Note]Note

GNU Make is available for most of the UNIX-like platforms.

If GNU Make isn’t already installed or available as a package for your platform, you can get it at: http://www.gnu.org/software/make/.

After correct installation:

$ make --version

should result in something like:

GNU Make 4.0
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
Licence GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Your version string may vary, of course.