Wireshark-dev: Re: [Wireshark-dev] Building on Windows with CMake: Status and help needed
From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Sun, 6 Oct 2013 14:01:10 +0100
On 5 October 2013 12:03, Joerg Mayer <jmayer@xxxxxxxxx> wrote:
Hello,

I've made some progress and am now able to almost build a first 32 bit
executable with VSEE2010. The executable (capinfos) using nmake as build tool.
The cmake stage (for nmake) is working as much as is needed, i.e. no GUI
package detection right now.
Compilation is working, but linking fails:
  capinfos.c.obj : error LNK2001: unresolved external symbol __imp__optind
  capinfos.c.obj : error LNK2019: unresolved external symbol __imp__getopt referenced in function _main
I've spent some hours digging into it but everything I've tried has failed.

Other open issues:
- The same warning over and over again:
  cl : Command line warning D9025 : overriding '/MD' with '/MDd'
- Problems with the WS_DLL_PUBLIC mechanism, one out of many examples:
  C:\wireshark\trunk\epan\plugins.c(31) : warning C4273: 'wslua_plugin_list' : inconsistent dll linkage
        c:\wireshark\trunk\epan\plugins.h(65) : see previous definition of 'wslua_plugin_list'

My next steps (not necessarily in that order):
- Try to get the remaining executables as close to linking as possible.
- GTK3 and GTK2 builds (gtk detection).
- Is there a recipe for Qt5 builds on Windows (esecially the qt5 package)?
- Go for 64 bit builds.

If someone feels motivated to help with any of the problems or unfinished
tasks above or anything else: Go ahead - I don't want a monoploly on this ;-)
Coordination via the list or IRC(freenode) #wireshark?

Full logs of a build of svn revision 52377
cmake -G "NMake Makefiles" ..\..\trunk
cmake --build . -- VERBOSE=1

can be found here:
http://www.loplof.de/kram/cmake.log
http://www.loplof.de/kram/build.log



Hi Joerg,

I was also working on this yesterday, but I was using CMake to build a Visual Studio solution (VS2010 Pro).  I was trying to get randpkt to build and at least one issue you mention (import of getopt) is where I had issues.

The issues I ran into were:

* Needed to add a definition for MSC_VER_REQUIRED to CMakeList.txt.  I cheated and just hacked in a fixed one for my version (MSC_VER_REQUIRED=1600).

* randpkt, and a lot of other things depend on wsutil.  CMake doesn't seem to add a dependency on wsutil though.

* wsutil on windows also requires 5 files to be added to WSUTIL_PLATFORM_FILES: inet_aton.c, inet_ntop.c, inet_pton.c, strptime.c, wsgetopt.c

* wsutil requires at least ws2_32.lib to link

I still can't produce a dll yet as the link fails looking for strncasecmp required by strptime_internal.  This has me stumped.  I checked what the normal nmake produced dll imports (using dumpbin /imports libwsutil.dll) and that function isn't listed.  I think it's something to do with all the macro wizardy in strptime.c

For what it's worth I think the link libs we supply are mostly far beyond what is needed, for this dll produced by the normal nmake build the dependences are (using dumpbin /dependents):

Dump of file ..\..\trunk\wireshark-gtk2\libwsutil.dll

File Type: DLL

  Image has the following dependencies:

    KERNEL32.dll

    WS2_32.dll

    ADVAPI32.dll

    SHELL32.dll

    libglib-2.0-0.dll

    libgmodule-2.0-0.dll

    libgcrypt-11.dll

    MSVCR100.dll

  Summary

        1000 .data

        C000 .rdata

        1000 .reloc

        1000 .rsrc

       11000 .text


I've also attached the build output for the dll from the normal nmake build and the CMake generated VS2010 build for comparison as there must be a vital difference somewhere.

        cl -WX /DPCAP_VERSION=4_1_3 /Zi /W3 /MD /DWIN32_LEAN_AND_MEAN /DMSC_VER_REQUIRED=1600  /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE -DPSAPI_VERSION=1 /D_BIND_TO_CURRENT_CRT_VERSION=1 /MP /GS /w34295  /I. /I.. /IE:\Wireshark\wireshark-win32-libs\gtk3\include\glib-2.0  /IE:\Wireshark\wireshark-win32-libs\gtk3\lib\glib-2.0\include  -DG_DISABLE_DEPRECATED  -DG_DISABLE_SINGLE_INCLUDES /IE:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\include /DNOCRYPT /DIMPORT_LIGNUTLSDLL  /IE:\Wireshark\wireshark-win32-libs\WPdpack\include -DWS_BUILD_DLL -Fd.\ -c file_util.c inet_aton.c inet_ntop.c inet_pton.c aes.c airpdcap_wep.c crash_info.c crc6.c crc7.c crc8.c crc10.c crc11.c crc16.c crc16-plain.c crc32.c crcdrm.c des.c eax.c g711.c md4.c md5.c mpeg-audio.c nstime.c privileges.c sha1.c strnatcmp.c str_util.c swar.c rc4.c report_err.c tempfile.c type_util.c u3.c strptime.c unicode-utils.c wsgetopt.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

file_util.c
inet_aton.c
inet_ntop.c
inet_pton.c
aes.c
airpdcap_wep.c
crash_info.c
crc6.c
crc7.c
crc8.c
crc10.c
crc11.c
crc16.c
crc16-plain.c
crc32.c
crcdrm.c
des.c
eax.c
g711.c
md4.c
md5.c
mpeg-audio.c
nstime.c
privileges.c
sha1.c
strnatcmp.c
str_util.c
swar.c
rc4.c
report_err.c
tempfile.c
type_util.c
u3.c
strptime.c
unicode-utils.c
wsgetopt.c
        link  /INCREMENTAL:NO /NOLOGO -entry:_DllMainCRTStartup@12 -dll kernel32.lib  ws2_32.lib mswsock.lib advapi32.lib shell32.lib  /DEBUG /MACHINE:x86 /SafeSEH /DYNAMICBASE /FIXED:no   /OUT:libwsutil.dll  /IMPLIB:libwsutil.lib  ..\image\libwsutil.res  file_util.obj            inet_aton.obj           inet_ntop.obj
         inet_pton.obj           aes.obj                 airpdcap_wep.obj
 crash_info.obj  crc6.obj                crc7.obj                crc8.obj
         crc10.obj               crc11.obj               crc16.obj
 crc16-plain.obj         crc32.obj               crcdrm.obj      des.obj
         eax.obj                 g711.obj                md4.obj
 md5.obj                 mpeg-audio.obj  nstime.obj      privileges.obj  sha1.obj                strnatcmp.obj   str_util.obj    swar.obj                rc4.obj                 report_err.obj  tempfile.obj    type_util.obj   u3.obj  strptime.obj            unicode-utils.obj       wsgetopt.obj E:\Wireshark\wireshark-win32-libs\gtk3\lib\glib-2.0.lib  E:\Wireshark\wireshark-win32-libs\gtk3\lib\gmodule-2.0.lib  E:\Wireshark\wireshark-win32-libs\gtk3\lib\gobject-2.0.lib   E:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\bin\libtasn1-3.lib  E:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\bin\libgpg-error-0.lib E:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\bin\libgcrypt-11.lib  E:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\bin\libgnutls-26.lib
   Creating library libwsutil.lib and object libwsutil.exp
Build started 06/10/2013 13:36:10.
     1>Project "E:\Wireshark\build\wsutil\wsutil.vcxproj" on node 2 (build target(s)).
     1>InitializeBuildStatus:
         Touching "wsutil.dir\Debug\wsutil.unsuccessfulbuild".
       CustomBuild:
         Building Custom Rule E:/Wireshark/trunk/wsutil/CMakeLists.txt
         CMake does not need to re-run because E:\Wireshark\build\wsutil\CMakeFiles\generate.stamp is up-to-date.
       ClCompile:
         c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /IE:/Wireshark/build /IE:/Wireshark/trunk /IE:/Wireshark/trunk/epan /IE:/Wireshark/trunk/tools/lemon /IE:/Wireshark/trunk/wiretap /I"e:/Wireshark/wireshark-win32-libs/c-ares-1.9.1-1-win32ws/include" /I"e:/Wireshark/wireshark-win32-libs/gnutls-2.12.18-1.2-win32ws/include" /I"e:/Wireshark/wireshark-win32-libs/GeoIP-1.5.1-2-win32ws/include" /I"e:/Wireshark/wireshark-win32-libs/gtk3/include/glib-2.0" /I"e:/Wireshark/wireshark-win32-libs/gtk3/lib/glib-2.0/include" /I"e:/Wireshark/wireshark-win32-libs/gtk3/include/glib-2.0/glib" /I"e:/Wireshark/wireshark-win32-libs/kfw-3-2-2-i386-ws-vc6/include" /I"e:/Wireshark/wireshark-win32-libs/lua5.1.4/include" /I"e:/Wireshark/wireshark-win32-libs/WpdPack/Include" /I"e:/Wireshark/wireshark-win32-libs/libsmi-svn-40773-win32ws/include" /I"e:/Wireshark/wireshark-win32-libs/zlib125/include" /Zi /nologo /W3 /WX- /MP /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D PCAP_VERSION= /D WIN32_LEAN_AND_MEAN /D MSC_VER_REQUIRED= /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _BIND_TO_CURRENT_CRT_VERSION=1 /D _DEBUG /D WS_BUILD_DLL /D "CMAKE_INTDIR=\"Debug\"" /D wsutil_EXPORTS /D _WINDLL /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"wsutil.dir\Debug\\" /Fd"E:/Wireshark/build/lib/Debug/wsutil.pdb" /Gd /TC /analyze- /errorReport:prompt ..\..\trunk\wsutil\aes.c ..\..\trunk\wsutil\airpdcap_wep.c ..\..\trunk\wsutil\crash_info.c ..\..\trunk\wsutil\crc10.c ..\..\trunk\wsutil\crc16.c "..\..\trunk\wsutil\crc16-plain.c" ..\..\trunk\wsutil\crc32.c ..\..\trunk\wsutil\crc6.c ..\..\trunk\wsutil\crc7.c ..\..\trunk\wsutil\crc8.c ..\..\trunk\wsutil\crc11.c ..\..\trunk\wsutil\crcdrm.c ..\..\trunk\wsutil\des.c ..\..\trunk\wsutil\eax.c ..\..\trunk\wsutil\g711.c ..\..\trunk\wsutil\md4.c ..\..\trunk\wsutil\md5.c "..\..\trunk\wsutil\mpeg-audio.c" ..\..\trunk\wsutil\nstime.c ..\..\trunk\wsutil\privileges.c ..\..\trunk\wsutil\sha1.c ..\..\trunk\wsutil\strnatcmp.c ..\..\trunk\wsutil\str_util.c ..\..\trunk\wsutil\rc4.c ..\..\trunk\wsutil\report_err.c ..\..\trunk\wsutil\swar.c ..\..\trunk\wsutil\tempfile.c ..\..\trunk\wsutil\type_util.c ..\..\trunk\wsutil\u3.c ..\..\trunk\wsutil\file_util.c ..\..\trunk\wsutil\inet_aton.c ..\..\trunk\wsutil\inet_ntop.c ..\..\trunk\wsutil\inet_pton.c ..\..\trunk\wsutil\strptime.c "..\..\trunk\wsutil\unicode-utils.c" ..\..\trunk\wsutil\wsgetopt.c  /w34295 
         aes.c
         airpdcap_wep.c
         crash_info.c
         crc10.c
         crc16.c
         crc16-plain.c
         crc32.c
         crc6.c
         crc7.c
         crc8.c
         crc11.c
         crcdrm.c
         des.c
         eax.c
         g711.c
         md4.c
         md5.c
         mpeg-audio.c
         nstime.c
         privileges.c
         sha1.c
         strnatcmp.c
         str_util.c
         rc4.c
         report_err.c
         swar.c
         tempfile.c
         type_util.c
         u3.c
         file_util.c
         inet_aton.c
         inet_ntop.c
         inet_pton.c
         strptime.c
     1>..\..\trunk\wsutil\strptime.c(348): warning C4013: 'strncasecmp' undefined; assuming extern returning int
     1>..\..\trunk\wsutil\file_util.c(462): warning C4133: 'function' : incompatible types - from 'TCHAR [260]' to 'const gunichar2 *'
     1>..\..\trunk\wsutil\file_util.c(473): warning C4133: 'function' : incompatible types - from 'TCHAR [260]' to 'const gunichar2 *'
     1>..\..\trunk\wsutil\file_util.c(498): warning C4133: 'function' : incompatible types - from 'wchar_t *' to 'LPCSTR'
         unicode-utils.c
         wsgetopt.c
     1>..\..\trunk\wsutil\unicode-utils.c(101): warning C4133: 'function' : incompatible types - from 'TCHAR *' to 'wchar_t *'
     1>..\..\trunk\wsutil\unicode-utils.c(101): warning C4133: 'function' : incompatible types - from 'char [3]' to 'const wchar_t *'
       ManifestResourceCompile:
         C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"wsutil.dir\Debug\wsutil.dll.embed.manifest.res" wsutil.dir\Debug\wsutil_manifest.rc 
       Link:
         c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"E:\Wireshark\build\lib\Debug\wsutil.dll" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ws2_32.lib mswsock.lib "e:\Wireshark\wireshark-win32-libs\gtk3\lib\gmodule-2.0.lib" "e:\Wireshark\wireshark-win32-libs\gtk3\lib\glib-2.0.lib" "e:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\bin\libgcrypt-11.lib" "e:\Wireshark\wireshark-win32-libs\gnutls-2.12.18-1.2-win32ws\bin\libgpg-error-0.lib" "E:\Wireshark\wireshark-win32-libs\gtk3\lib\gobject-2.0.lib" /MANIFEST /ManifestFile:"wsutil.dir\Debug\wsutil.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"E:/Wireshark/build/lib/Debug/wsutil.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"E:/Wireshark/build/lib/Debug/wsutil.lib" /MACHINE:X86 /DLL wsutil.dir\Debug\wsutil.dll.embed.manifest.res
         wsutil.dir\Debug\aes.obj
         wsutil.dir\Debug\airpdcap_wep.obj
         wsutil.dir\Debug\crash_info.obj
         wsutil.dir\Debug\crc10.obj
         wsutil.dir\Debug\crc16.obj
         "wsutil.dir\Debug\crc16-plain.obj"
         wsutil.dir\Debug\crc32.obj
         wsutil.dir\Debug\crc6.obj
         wsutil.dir\Debug\crc7.obj
         wsutil.dir\Debug\crc8.obj
         wsutil.dir\Debug\crc11.obj
         wsutil.dir\Debug\crcdrm.obj
         wsutil.dir\Debug\des.obj
         wsutil.dir\Debug\eax.obj
         wsutil.dir\Debug\g711.obj
         wsutil.dir\Debug\md4.obj
         wsutil.dir\Debug\md5.obj
         "wsutil.dir\Debug\mpeg-audio.obj"
         wsutil.dir\Debug\nstime.obj
         wsutil.dir\Debug\privileges.obj
         wsutil.dir\Debug\sha1.obj
         wsutil.dir\Debug\strnatcmp.obj
         wsutil.dir\Debug\str_util.obj
         wsutil.dir\Debug\rc4.obj
         wsutil.dir\Debug\report_err.obj
         wsutil.dir\Debug\swar.obj
         wsutil.dir\Debug\tempfile.obj
         wsutil.dir\Debug\type_util.obj
         wsutil.dir\Debug\u3.obj
         wsutil.dir\Debug\file_util.obj
         wsutil.dir\Debug\inet_aton.obj
         wsutil.dir\Debug\inet_ntop.obj
         wsutil.dir\Debug\inet_pton.obj
         wsutil.dir\Debug\strptime.obj
         "wsutil.dir\Debug\unicode-utils.obj"
         wsutil.dir\Debug\wsgetopt.obj  /machine:X86 /debug 
            Creating library E:/Wireshark/build/lib/Debug/wsutil.lib and object E:/Wireshark/build/lib/Debug/wsutil.exp
     1>strptime.obj : error LNK2019: unresolved external symbol _strncasecmp referenced in function _strptime_internal
     1>E:\Wireshark\build\lib\Debug\wsutil.dll : fatal error LNK1120: 1 unresolved externals
     1>Done Building Project "E:\Wireshark\build\wsutil\wsutil.vcxproj" (build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:01.61