Reputation: 940
I'm trying to compile LibTIFF on Windows. The library needs to be built with CMake. I try to build with Visual Studio 2015. But CMake complains "The C++ compiler is not able to compile a simple test program".
However, building with Visual Studio 2022 is OK.
Here is the command I used to build with VS2015 and the error message.
C:\Users\Cosmo\code>cmake -S tiff-4.5.0 -B tiff-4.5.0-build -G "Visual Studio 14 2015" -A x64
-- Building tiff version 4.5.0
-- libtiff library version 6.0.0
-- libtiff build date: 20231205
-- Selecting Windows SDK version to target Windows 10.0.22621.
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe cmTC_6bee4.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=14.0 /v:m && Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error : The source file for this compilation can be found at: "C:\Users\Cosmo\AppData\Local\Temp\c8d67cd1-d780-4aa5-a9cb-beaa0d8b5640.txt" [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_6bee4.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB3758: An error has occurred during compilation. c:\Users\Cosmo\AppData\Local\Temp\xui5qmvs.0.cs(1,13) : error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_6bee4.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB3758: An error has occurred during compilation. c:\Users\Cosmo\AppData\Local\Temp\xui5qmvs.0.cs(1,1) : error CS0116: A namespace cannot directly contain members such as fields or methods [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_6bee4.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB4036: The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\14.0\bin" directory. [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_6bee4.vcxproj]
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:44 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeError.log".
Here are the relevant log files:
Why is this happening and how to solve it?
By the way, it's really weird that CMake try to test a C++ compiler with C# source code. What's the consideration here?
Sometimes it's not able to reproduce this problem. The check for C++ compiler is always "skipped" but not "broken". I cannot figure out how to make sure to reproduce or not reproduce it. However, as the checking procedure is "skipped", not something like "passed" or "completed", I suppose this problem is not solved yet even if I cannot reproduce it.
On this case, as the checking procedure is skipped, I can go further with the CMake process. It then fails at check_type_size("size_t" SIZEOF_SIZE_T)
. I don't know if it is relevant.
Here is the full output of this case:
-- Building tiff version 4.5.0
-- libtiff library version 6.0.0
-- libtiff build date: 20231212
-- Selecting Windows SDK version to target Windows 10.0.22621.
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - skipped-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test C_FLAG_W3
-- Performing Test C_FLAG_W3 - Success
-- Performing Test HAVE_LD_VERSION_SCRIPT
-- Performing Test HAVE_LD_VERSION_SCRIPT - Failed
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for io.h
-- Looking for io.h - found
-- Looking for strings.h
-- Looking for strings.h - not found
-- Looking for sys/time.h
-- Looking for sys/time.h - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for getopt
-- Looking for getopt - not found
-- Looking for optarg
-- Looking for optarg - not found
-- Looking for mmap
-- Looking for mmap - not found
-- Looking for setmode
-- Looking for setmode - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of size_t
-- Check size of size_t - failed
CMake Error at cmake/TypeSizeChecks.cmake:53 (message):
Unsupported size_t size ; please add support
Call Stack (most recent call first):
CMakeLists.txt:95 (include)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeError.log".
And possible helpful files:
NOTE THAT I'm using the VS2015 command line, by running C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat
.
I've tried another Windows SDK 10.0.18362.0 and 8.1, but neither made difference. For example:
C:\Users\Cosmo\code>cmake -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -S tiff-4.5.0 -B tiff-4.5.0-build -G "Visual Studio 14 2015" -A x64
-- Building tiff version 4.5.0
-- libtiff library version 6.0.0
-- libtiff build date: 20231212
-- Selecting Windows SDK version to target Windows 10.0.18362.0.
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe cmTC_69a44.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=14.0 /v:m && Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error : The source file for this compilation can be found at: "C:\Users\Cosmo\AppData\Local\Temp\23bf9f9b-cdbc-4daf-9af0-759624b2fd63.txt" [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_69a44.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB3758: An error has occurred during compilation. c:\Users\Cosmo\AppData\Local\Temp\33ouyjy5.0.cs(1,13) : error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_69a44.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB3758: An error has occurred during compilation. c:\Users\Cosmo\AppData\Local\Temp\33ouyjy5.0.cs(1,1) : error CS0116: A namespace cannot directly contain members such as fields or methods [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_69a44.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB4036: The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\14.0\bin" directory. [C:\Users\Cosmo\code\tiff-4.5.0-build\CMakeFiles\CMakeTmp\cmTC_69a44.vcxproj]
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:44 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Cosmo/code/tiff-4.5.0-build/CMakeFiles/CMakeError.log".
Relevant log files:
Upvotes: 0
Views: 207