How to fix Cmake The PLATFORM environment variable (x64) doesn't match the generator platform (win32)

asked 2020-08-04 11:54:58 +0000

Eddy gravatar image

updated 2020-08-04 12:32:26 +0000

Building in Windows Sandbox with

choco install -y winflexbison3 cmake activeperl python3 asciidoctorj xsltproc docbook-bundle visualstudio2019community visualstudio2019-workload-nativedesktop

Command prompt is titled "Administator: x64 Native Tools Command Prompt for VS 2019" and opens claiming to be "Visual Studio 2019 Developer Command Prompt v16.6.5".

WIRESHARK_BASE_DIR and QT5_BASE_DIR are set

cmake -G "Visual Studio 16 2019" -A x64 ..\wireshark-3.2.5

quits with:

CMake Error at CMakeLists.txt:91 (message):
  The PLATFORM environment variable (x64) doesn't match the generator
  platform (win32)

Also set WIRESHARK_TARGET_PLATFORM=win64 does not fix this. Any ideas how to persuade this to work?

Set reports:

Platform=x64
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
edit retag flag offensive close merge delete

Comments

After opening the prompt, the banner should look like this:

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.5
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

and the last line indicates the target.

What does set VSCMD_ARG_TGT_ARCH report?

grahamb gravatar imagegrahamb ( 2020-08-04 12:12:35 +0000 )edit

And you should be setting QT5_BASE_DIR.

Another thought, are you using a build directory that you've previously configured CMake for an x86 build? If so, create a new build dir, the x64 and x86 builds MUST be kept separate.

grahamb gravatar imagegrahamb ( 2020-08-04 12:17:00 +0000 )edit

** Visual Studio 2019 Developer Command Prompt v16.6.5
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>set VSCMD_ARG_TGT_ARCH
VSCMD_ARG_TGT_ARCH=x64

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd \Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>dir
 Volume in drive C has no label.
 Volume Serial Number is C436-650E

 Directory of C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64

08/04/2020  12:57 PM    <DIR>          .
08/04/2020  12:57 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  80,356,634,624 bytes free

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>set WIRESHARK_BASE_DIR=C:\Users\WDAGUtilityAccount\Desktop\wireshark

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>set QT5_BASE_DIR=C:\Qt\Qt5.12.1\5.12.1\msvc2017_64

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>cmake -G "Visual Studio 16 2019" -A x64 ..\wireshark-3.2.5
Eddy gravatar imageEddy ( 2020-08-04 12:33:36 +0000 )edit

More output:

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI ...
(more)
Eddy gravatar imageEddy ( 2020-08-04 12:58:50 +0000 )edit

This bit of output is odd, not sure what that means:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown

It should be something like:

-- The C compiler identification is MSVC 19.26.28806.0
-- The CXX compiler identification is MSVC 19.26.28806.0

The check in CMakeList.txt is failing because the WIRESHARK_TARGET_PLATFORM variable is incorrect ("win32").

That is set by the block:

if(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES "Win64")
    set(WIRESHARK_TARGET_PLATFORM win64)
elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
    set(WIRESHARK_TARGET_PLATFORM win32)
else()
    set(WIRESHARK_TARGET_PLATFORM $ENV{WIRESHARK_TARGET_PLATFORM})
endif()



So I would assume that the first conditional evaluates to false and the second to true. Can you add some debugging message(STATUS "...") items to dump out the value of {CMAKE_CL_64} and {CMAKE_GENERATOR}, e.g.

message(STATUS "CMAKE_CL_64: ${CMAKE_CL_64}, CMAKE_GENERATOR:${CMAKE_GENERATOR}")

add it just in front of the above block.

grahamb gravatar imagegrahamb ( 2020-08-04 13:56:56 +0000 )edit

-- CMAKE_CL_64: , CMAKE_GENERATOR:Visual Studio 16 2019

I still see the error if I

SET WIRESHARK_TARGET_PLATFORM=win64

before running CMake

Eddy gravatar imageEddy ( 2020-08-04 14:03:51 +0000 )edit

OK, so the CMakeLists.txt expects CMAKE_CL_64 to be TRUE, and it isn't in your case. That's set by CMake if it's using an MS 64 bit compiler. I suspect this is tied up with the unknown compiler output

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown

Is it possible you have other compilers in your path? Can you show the PATH env var?

grahamb gravatar imagegrahamb ( 2020-08-04 14:12:36 +0000 )edit

Path:

Path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Windows Kits\10\bin\10 ...
(more)
Eddy gravatar imageEddy ( 2020-08-04 19:38:55 +0000 )edit

And there shouldn't be any other compilers - it's a fresh Windows Sandbox

Eddy gravatar imageEddy ( 2020-08-04 19:39:24 +0000 )edit

Formatted for better inspection:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\
C:\Program Files (x86)\Windows Kits\10 ...
(more)
grahamb gravatar imagegrahamb ( 2020-08-04 19:42:58 +0000 )edit

You might want to have a look at the CMake output generated by the Windows Server 2019 x64 buildbot and compare that output with yours. (All master buildbots can be found here: https://buildbot.wireshark.org/wiresh...) You may discover differences that are adversely affecting your ability to build Wireshark, and it's certainly possible that the documentation for building Wireshark may be to blame and not necessarily anything that you did wrong specifically, especially if you closely followed the documentation for setting up the build environment as documented at https://www.wireshark.org/docs/wsdg_h.... At least a few things seem out-of-date with the documentation in that it mentions:

  • "For example, at the time of this writing the Qt 5.12.1 “msvc2017 64-bit” component is used to build the official 64-bit packages.", but that's not true as Qt 5.12.8 is used.
  • "e.g. C:\Qt ...
(more)
cmaynard gravatar imagecmaynard ( 2020-08-05 02:25:21 +0000 )edit

@cmaynard Great suggestion to look at the build slaves, in this case I would suggest the 3.2 set as the user is trying to build 3.2.5. For this specific case look at the Windows Server 2019 X64 builder and the "ran cmake" step, clicking on the stdio link to see the command, the env vars and output of running the CMake generation phase. There are some annoying CMake warnings there that should be fixed.

While the docs could use an update, the exact versions of Qt 5.12, Python, Perl et al don't really matter as CMake will locate them.

The Qt install path is wherever the user decides to put it, IIRC Qt have moved things about a bit, the key bit is the supplied path should end in the appropriate compiler\build version as in "msvc2017_64".

The issue here is that CMake isn't ...(more)

grahamb gravatar imagegrahamb ( 2020-08-05 07:19:06 +0000 )edit