This is a static, read-only archive of Wireshark Q&A. Older questions and answers from October 2017 and earlier can be found at osqa-ask.wireshark.org.
0

Getting error MSB4018 when trying to build wireshark sources

asked Nov 14 '17

updated Nov 14 '17

Hi, I followed Quick setup guide found here: https://www.wireshark.org/docs/wsdghtmlchunked/ChSetupWin32.html and installed and configured everything as described. But when I tried to compile the latest wireshark sources I received many errors like that:

"C:\wiresharkDev\wsbuild32\Wireshark.sln" (default target) (1) ->
  "C:\wiresharkDev\wsbuild32\ui\ui.vcxproj.metaproj" (default target) (57) ->
    "C:\wiresharkDev\wsbuild32\ui\ui.vcxproj" (default target) (93) ->
     C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB4018: The "CustomBuild" task failed unexpectedly.\r [C:\wiresharkDev\wsbuild32\ui\ui.vcxproj]

Could anybody help me to solve it? Many thanks, Bella

Comments

Please show the full output of the CMake generation step, redirect to a file as shown below, copy the file to a public file sharing site, e.g. Google Drive, DropBox etc. and then post a link to the file in a comment.

CMake "Your arguments" 2>&1 > cmake.txt
User 98587 ( Nov 14 '17 )

Thank you for helping me with this issue! According to your request I used this command

cmake -DENABLE_CHM_GUIDES=on -G "Visual Studio 14" ..\wireshark 2>&1 > cmake.txt.

cmake.txt could be found here: link text

User 43459 ( Nov 14 '17 )

1 Answer

0

answered Nov 14 '17

From your CMake output:

-- The following OPTIONAL packages have not been found:

* CAP
* Gettext
* M
* Qt5Core
* Qt5LinguistTools
* Qt5Multimedia
* Qt5PrintSupport
* Qt5Svg
* Qt5Widgets
* Qt5WinExtras
* SETCAP
* PkgConfig
* LYNX

The others are expected and OK on Windows, but the Qt ones are not. Your build environment for Qt is not setup correctly as per the Developers Guide Sect 2.2.3, either you haven't installed Qt or you haven't set the QT5_BASE_DIR environment variable.

Comments

I use the following settings:

set CYGWIN=nodosfilewarning   
set WIRESHARK_BASE_DIR=C:\wiresharkDev   
set WIRESHARK_TARGET_PLATFORM=win32   
set QT5_BASE_DIR=C:\Qt\Qt5.9.2\vcredist\vcredist_msvc2015_x86.exe   
set WIRESHARK_VERSION_EXTRA=-bella

What's wrong here?

User 43459 ( Nov 14 '17 )

You have the wrong path set in QT5_BASE_DIR. It should be C:\Qt\Qt5.9.2\msvc2015.

User 98587 ( Nov 14 '17 )

But there is no msvc2015 directory under C:\Qt\Qt5.9.2 What does it mean?

User 43459 ( Nov 14 '17 )

Somewhere under C:\Qt you should be able to find windeployqt.exe, that's usually in a "bin" directory. You need to set QT5_BASE_DIR to the directory above the "bin" directory.

For example I have (using Qt 5.9.1):

C:\Qt
  \5.9.1
    \msvc_2015    <--- set QT5_BASE_DIR to here.
      \bin
        \windeployqt.exe
User 98587 ( Nov 14 '17 )

Thanks a lot for your great help! I understood the issue finally – it was related to wrong QT installation. When installing you need to select QT 5.9.2 -> msvc 2015 32 bit ( it was not selected by default). That’s why I didn’t have a folder containing windeployqt.exe. Now QT5_BAS_DIR set to C:\Qt\Qt5.9.2\5.9.2\msvc2015 - you can find cmake.txt file here

But when I compile I end up with the same errors that I started from:

"C:\wiresharkDev\wsbuild32\Wireshark.sln" (default target) (1) ->
       "C:\wiresharkDev\wsbuild32\codecs\wscodecs.vcxproj.metaproj" (default target) (75) ->
       "C:\wiresharkDev\wsbuild32\codecs\wscodecs.vcxproj" (default target) (110) ->
         C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB4018: The "CustomBuild" task failed unexpectedly.\r [C:\wiresharkDev\wsbuild32\codecs\wscodecs.vcxproj]
       C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB4018: System.IO.IOException: The process cannot access the file 'C:\Users\belsht01\AppData\Local\Temp\tmp37a8515ee59548b4997
       12db05666fa00.cmd' because it is being used by another process.\r [C:\wiresharkDev\wsbuild32\codecs\wscodecs.vcxproj]
       C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB4018:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r [C:\wiresharkDev\wsbuild32\codecs\wscodecs.vcxproj]
       C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB4018:    at System.IO.File.InternalDelete(String path, Boolean checkHost)\r [C:\wiresharkDev\wsbuild32\codecs\wscodecs.vcxproj]
       C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB4018:    at System.IO.File.Delete(String path)\r [C:\wiresharkDev\wsbuild32\code
User 43459 ( Nov 14 '17 )

Did you scratch your build dir and re ran cmake?

User 9023 ( Nov 14 '17 )

Well, I erased both wsbuild32 and wireshark-win32-libs directories and re-created wsbuild32.

After that I run cmake -DENABLE_CHM_GUIDES=on -G "Visual Studio 14 2015" ..\wireshark 2>&1 > cmake.txt and cmake.txt could be found here

Then I run msbuild /m /p:Configuration=RelWithDebInfo Wireshark.sln /t:Clean and after that msbuild /fl /flp:verbosity=diagnostic /m /p:Configuration=RelWithDebInfo Wireshark.sln msbuild.log is located here

Any idea?

User 43459 ( Nov 15 '17 )

Your CMake output looks OK.

The format of build output you are using is far too verbose, in addition it helps to turn off parallel builds (drop the /m) when debugging build output.

Please use msbuild /p:Configuration=RelWithDebInfo 2>&1 > build.txt to produce a build output file.

User 98587 ( Nov 15 '17 )

You can find build.txt file here: link text

User 43459 ( Nov 15 '17 )

Your build output looks OK, you should have a Wireshark.exe to test in C:\wiresharkDev\wsbuild32\run\RelWithDebInfo.

User 98587 ( Nov 15 '17 )

Interesting that I didn't do anything but dropped /m from the build command. And yes, now I have Wireshark.exe that tries to start and fails a second later.

I checked the stack,(not sure that it's ok) and it looks as follows:

software_update_init() line 109
WiresharkApplication::allSystemGo() line 1122
main line 845

and it looks like the problem is in these lines (in softwareupdateinit function):

if (strcmp(language, "system") != 0) {
        win_sparkle_set_lang(language);
}
User 43459 ( Nov 15 '17 )

Yep, that was a null pointer dereference that was fixed in change 24414. Update your sources to get the fix.

User 98587 ( Nov 15 '17 )

Thank you! Will try now But can you explain why the build is OK now after I dropped /m? What does his parameter do?

User 43459 ( Nov 15 '17 )

The /m allows multiple projects to be built in parallel across all the cores in your build machine. I use it all the time on my 4 core build VM's, as do the Wireshark build slaves (not sure how many cores they have) without issue. I remove it when debugging build output so that projects are then built in order and it's easier to read.

If the original answer has solved your problem (which was an incorrect Qt install) please accept it by clicking the "checkmark" icon.

User 98587 ( Nov 15 '17 )

The original answer did help me to find QT installation issue, but there are still weird issues related to original question - error MSB4018. I still cannot figure out what cause it why it disappeared after I dropped /m. And now - I rebuilt it with the NULL pointer fix and despite of the fact that I run it without /m the build failed with the same errors - new build.txt attached link text

User 43459 ( Nov 15 '17 )

Arguably this is a different question even if the symptoms are similar so should get a new one.

Anyway, the errors in your latest build relate to an inability to open zlib1.dll and what seems to be parallel build conflicts when building the docs. I'm uncertain why you get these, do you have wireshark open when building, or maybe it's caused by AV locking the files?

I also don't know why your subsequent build is attempting to rebuild the docs, it should be incremental, i.e. only what's changed. Are you doing a /t:clean between each build or adding /t:rebuild, if so neither should be required?

User 98587 ( Nov 15 '17 )

Well, after several iterations I can definitely tell that my original issue (error MSB4018 The "CustomBuild" task failed unexpectedly) is related to presence of /m flag.

If I run clean command without /m
msbuild /p:Configuration=RelWithDebInfo Wireshark.sln /t:Clean
and after that build command without /m as well:
msbuild /p:Configuration=RelWithDebInfo Wireshark.sln
everything works well. It makes me crazy, but at least the work-around found.

Anyway, thanks a lot for your great help!

User 43459 ( Nov 15 '17 )

I rarely run clean, but if I do it has the /m as I cut and paste and I most often build with /m, but most builds are incremental because I rarely clean.

If things really go screwy then take the nuclear option and delete the build directory, recreate and rerun CMake and build afresh.

User 98587 ( Nov 15 '17 )

that's what I did usually but now when I tried to create environment for wireshark on my new laptop I started failing on various issues that I never faced before - QT installation usually worked automatically and I had never seen this MSB4018. I will continue to investigate the issue, but things look better since I have a work-around :)

User 43459 ( Nov 15 '17 )

Pro-tip, create a VM purely for Wireshark development. Easy to back-up and copy to new machine. Need a Windows licence for it though.

User 98587 ( Nov 15 '17 )

good point I will think it over! Thank you again!

User 43459 ( Nov 15 '17 )
cc-by-sa Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.