QT - Set windows platform version - windows

I updated my Windows version to 10.0.15063.0 and every lib is missing, so I had to change the platform version to 10.0.14393.0 on Visual Studio, is there any equivalent for QT? The reason I ask is because QT seems to be using the 10.0.15063.0 version and so I get errors like kernel.lib / shell32.lib are missing, etc.

Option 1
You need to install the Windows 10 SDK for 10.0.15063.0
If you have Visual Studio 2017 installed this can be done by using the "Visual Studio Installer". In "Individual components", check "Windows 10 SDK (10.0.15063.0) for Desktop C++ x86 and x64" and apply the changes.
Option 2
Command line
If you build your project from the command line you can specify which Windows kit you want to use when calling vcvarsall.bat
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 10.0.14393.0
Qt Creator
If you use Qt Creator, the call to vcvarsall.bat is made automatically. You can see the call in Qt Creator settings in "Build & Run" > "Compilers".
However the GUI does not provide a mean to add extra arguments to the command line.
You might be able to force the arguments by editing C:\Users\<username>\AppData\Roaming\QtProject\qtcreator\toolchains.xml. This file should contains something like:
<value type="QString" key="ProjectExplorer.MsvcToolChain.VarsBat">C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat</value>
<value type="QString" key="ProjectExplorer.MsvcToolChain.VarsBatArg">x86</value>
You could change it to:
<value type="QString" key="ProjectExplorer.MsvcToolChain.VarsBat">C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat</value>
<value type="QString" key="ProjectExplorer.MsvcToolChain.VarsBatArg">x86 10.0.14393.0</value>
But keep in mind that you are not supposed to edit this file by hand and it may or may not work.

Related

Visual Studio 2022: Cannot open include file: 'ctype.h'

I've got the infamous error message in C++ build: "Cannot open include file: 'ctype.h'". I know a similar question was already asked multiple times, but my case seems different because I am using the latest Visual Studio 2022 and seems to behave differently.
I have a bunch of existing C++ projects, they use plain 32-bit Windows API with DirectX 6, and I used VC++ build tools 2015 and Windows SDK 8.1 to compile it without any issues in previous versions of Visual Studio. Everything was fine in Visual Studio 2019, no special setup was needed, until I uninstalled it and installed Visual Studio 2022.
Now I can open my solutions, it nicely shows they are using C++ build tools 2015, which I installed together with VS2022, and the solutions also shows correctly that they use Windows 8.1 SDK. But Windows 8.1 SDK is not present in VS2022 installation, I installed it separately. I also tried to "repair" VS2022 installation, but that only deleted all my UI preferences, but not fixed anything in build. Also, I tried to reinstall Windows 8.1 SDK, but it said it is already OK.
When looking to Visual Studio, I can't see any place where I can set default include and lib directories, I can only list what is being used right now. VS2022 shows this list:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
C:\Program Files\Windows Kits\10\Include\10.0.10240.0\ucrt
C:\Program Files (x86)\Windows Kits\8.1\Include\um
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt
The actual error message I receive is this:
c:\program files (x86)\windows kits\8.1\include\um\winnt.h(31): fatal error C1083: Cannot open include file: 'ctype.h': No such file or directory
So it says that winnt.h from windows kits 8.1 cannot find ctype.h. And yes, there is no ctype.h in that folder or anywhere around, I can see it only in C:\Program Files\Microsoft Visual Studio\2022\Professional\SDK\ScopeCppSDK\vc15\SDK\include\ucrt
which I think is the folder with VC++ 2015 build tools. So this seems correct, but I am wondering why this folder is not a part of default include directories when VC++ 2015 build tools are set in project settings. Because it seems that VS2022 is correctly picking my Windows 8.1 SDK, but not picking correctly the older C++ compiler.
When I try to add the folder where ctype.h resides to include folders, I receive another type of errors saying that other files are incompatible with these include files. Of course, this system of directories needs to be in sync. So please what is the correct way of using this?
Also, I tried to switch the VC++ build tools to 2022 version. Unfortunately, that also does not fix the issue. And Windows 10 SDK is not installed, the software wants to stay compatible with older Windows, so I don't need it.
I found a bug report which is related: https://developercommunity.visualstudio.com/t/windows-81-sdk-1/151682
Although Microsoft staff declined to accept it as a bug, it is happening for me as well. When I install only Windows 8.1 SDK, no project can be compiled with it. I even tried to create a new Windows API project in VS2022, the project was created, but failed to compile with the same error.
So I tried to install Windows 10 SDK (from VS2022 installed, but that is probably not important) and this added some missing files which now help to compile Windows 8.1 SDK projects. Problem seems to be solved, my old C++ code can now be compiled with Windows 8.1 SDK and both C++ build tools 2015 and 2022.

CMake and Visual Studio: failed to run MSBuild.exe

I'm trying to build the OpenCV's source files and generate a Visual Studio project using CMake. I'm facing a problem that seems not solved neither with these given following recommendations: here - select the Visual Studio's correct version (e.g. v16 2019) when building with CMake, install MSBuild.exeand add its location to the system PATH -, here - install Windows SDK - and here - install required workload in Visual Studio regarding CMake/C++ and reboot it.
Then I ask for your kind help. I'm currently working with:
OS: Windows 8.1 Pro 64 bits
CMake (GUI) Version 3.17.2, located at C:\Program Files\CMake\bin
Microsoft Visual Studio 2019 version 16.6.0
MSBuild. exe version 16.6.0, located at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
OpenCV 4.3.0, located at D:\opencv;
sdksetup.exe version 8.100, located at C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1\StandaloneSDK
My Path in my system's environment variables is: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\MinGW\bin;C:\Program Files\CMake\bin\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\;C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\
I open the CMake with admin rights, then select "Visual Studio 16 2019" as generator, and I always got the following error pop-up when clicking in the "Configure" button:
Error in configuration process, projects files may be invalid.
I tried to do it with two different CMakeLists.txt, a simple one and a complete one.
The simple script
# cmake needs this line
cmake_minimum_required(VERSION 3.1)
# Define project name
project(opencv_example_project)
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
find_package(OpenCV REQUIRED)
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
# Declare the executable target built from your sources
add_executable(opencv_example example.cpp)
# Link your application with OpenCV libraries
target_link_libraries(opencv_example PRIVATE ${OpenCV_LIBS})
In this case, the status bar warned:
CMake Error at CMakeLists.txt:5 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft(R) Build Engine versÆo 16.6.0+5ff7b0c9e para .NET Framework
Copyright (C) Microsoft Corporation. Todos os direitos reservados.
The complete script
Which can be found here https://github.com/opencv/opencv/blob/master/CMakeLists.txt. I took care to delete all CMakeCache files and to delete cache inside CMake-GUI.
In this case, the status bar warned:
CMake Error at CMakeLists.txt:106 (enable_language):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft(R) Build Engine versÆo 16.6.0+5ff7b0c9e para .NET Framework
Just to finish: in "About" section inside Microsoft Visual Studio, we can see which Workloads were loaded:
Microsoft Visual Studio Community 2019
Version 16.6.0
VisualStudio.16.Release / 16.6.0 + 30114.105
Microsoft .NET Framework
Version 4.8.03761
Installed Version: Community
Visual C ++ 2019 00435-60000-00000-AA905
Microsoft Visual C ++ 2019
Test Adapter for Google Test 1.0
Enables Visual Studio testing tools with recorded unit tests for Google Test. The terms of use and Third Party Notices are available in the extension's installation directory.
ASP.NET and Web Tools 2019 16.6.936.3669
ASP.NET and Web Tools 2019
Microsoft Visual C ++ 1.0 wizards
Microsoft Visual C ++ wizards
IntelliCode 1.0 extension
Detailed IntelliCode Extension Information for Visual Studio
Tools C # 3.6.0-4.20251.5 + 910223b64f108fcf039012e0849befb46ace6e66
C # components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual Basic Tools 3.6.0-4.20251.5 + 910223b64f108fcf039012e0849befb46ace6e66
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual Studio tools for CMake 1.0 (interesting)
Visual Studio tools for CMake (uhmm okay)
NuGet Package Manager 5.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Visual Studio Code 1.0 Debug Adapter Host Package
Interoperability layer to host Visual Studio Code debug adapters in Visual Studio
Microsoft Visual Studio 1.0 VC package
Microsoft Visual Studio VC package
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Visual C ++ for Multiplatform Mobile Development (Android) 16.0.30014.67
Visual C ++ for Multiplatform Mobile Development (Android)
Thanks a lot!

Where are the x64 and ARM Developer Prompts for VS2017?

I installed the Visual Studio 2017 Build Tools. After installation, there's only an x86 Developer Command Prompt when navigating Start → Programs → Visual Studio 2017 → Visual Studio Tools. There are no prompts for x64 and ARM. (Usually there's about 6 developer prompts to choose from).
Where are the build tools for x64 and ARM located?
UPDATE (JAN-18-2017)
After installing the entire Windows 10 SDK, Build 15003 per #magicandre1981 instructions, I cannot find the Developer Prompts. I can't find them in the Start menu; and dropping into a Git Bash shell and searching for them returns 0 results.
In the names below, vsdevcmd.bat is what was installed by the VC++ Build Tools for 2017. vcbuildtools.bat is what was installed by the VC++ Build Tools for 2015.
MINGW64 /c/Program Files (x86)/Windows Kits/10
$ find . -iname 'vsdevcmd.*'
$ find . -iname 'vcbuildtools.*'
$ find . -iname '*.bat'
$ find . -iname '*.cmd'
./bin/10.0.15003.0/arm/SecureBoot/DeleteKitsPolicy.cmd
./bin/10.0.15003.0/arm/SecureBoot/InstallKitsPolicy.cmd
./bin/10.0.15003.0/arm64/install-sampleprovider.cmd
./bin/10.0.15003.0/arm64/uninstall-sampleprovider.cmd
./bin/10.0.15003.0/x64/install-sampleprovider.cmd
./bin/10.0.15003.0/x64/uninstall-sampleprovider.cmd
./bin/10.0.15003.0/x86/DismFoDInstall.cmd
./bin/10.0.15003.0/x86/GenerateUnionWinMD.cmd
./bin/10.0.15003.0/x86/install-sampleprovider.cmd
./bin/10.0.15003.0/x86/uninstall-sampleprovider.cmd
./bin/arm/SecureBoot/DeleteKitsPolicy.cmd
./bin/arm/SecureBoot/InstallKitsPolicy.cmd
./bin/arm64/install-sampleprovider.cmd
./bin/arm64/uninstall-sampleprovider.cmd
./bin/x64/install-sampleprovider.cmd
./bin/x64/uninstall-sampleprovider.cmd
./bin/x86/DismFoDInstall.cmd
./bin/x86/GenerateUnionWinMD.cmd
./bin/x86/install-sampleprovider.cmd
./bin/x86/uninstall-sampleprovider.cmd
./Debuggers/x64/srcsrv/cv2http.cmd
./Debuggers/x64/srcsrv/cvsindex.cmd
./Debuggers/x64/srcsrv/p4index.cmd
./Debuggers/x64/srcsrv/ssindex.cmd
./Debuggers/x64/srcsrv/svnindex.cmd
./Debuggers/x64/srcsrv/tfsindex.cmd
./Debuggers/x64/srcsrv/vssindex.cmd
./Debuggers/x64/srcsrv/walk.cmd
./Debuggers/x86/srcsrv/cv2http.cmd
./Debuggers/x86/srcsrv/cvsindex.cmd
./Debuggers/x86/srcsrv/p4index.cmd
./Debuggers/x86/srcsrv/ssindex.cmd
./Debuggers/x86/srcsrv/svnindex.cmd
./Debuggers/x86/srcsrv/tfsindex.cmd
./Debuggers/x86/srcsrv/vssindex.cmd
./Debuggers/x86/srcsrv/walk.cmd
./Windows Performance Toolkit/gpuview/log.cmd
./Windows Performance Toolkit/gpuview/log_mem.cmd
./Windows Performance Toolkit/WdfPerfEnhancedVerifier.cmd
$
Out of desperation, I copied the 2017 Build Tools Developer Prompt (for x86), and added the amd64_arm as the 2015 build tools does. It results in a failure:
[ERROR:parse_cmd.bat] Invalid command line argument: 'amd64_arm'. Argument will
be ignored.
**********************************************************************
** Visual Studio 2017 RC Developer Command Prompt v15.0
** Copyright (c) 2016 Microsoft Corporation
**********************************************************************
[ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be inc
omplete and/or incorrect. ***
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools>
More desperation... I started tracing the msiexec installers using process monitor, and examining MSI contents using 7-zip. The best I can tell, there are no developer prompts, even in the Developer Tools MSI installer:
The developer prompt bat files seem to have been restructured a little in VS 2017. Instead of having a fixed set of predefined developer prompts, you can customize it even more now.
To get a developer prompt for e.g. arm, add -arch=arm -host_arch=amd64 as parameters to VsDevCmd.bat (e.g. in the shortcut in the start menu).
For the full list of available options, have a look in \Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd\core\parse_cmd.bat, or call "\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd" -help.
I'm not sure if this really is documented anywhere, or if it will be fixed up and/or documented better for the final release of VS 2017.
Installing the insider preview Windows 10 SDK is unrelated to this; the standalone Windows SDK doesn't include any compilers, only headers and link libraries.
Install the Windows 10 SDK and WDK (at least Build 16299) to get the ARM Compiler for Desktop Applications.
Open the Project configuration and create ARM(64) configuration:
If you try to compile it you would get an error that ARM64 is not supported for Desktop:
To fix this, unload the project and open it in editor and add the line <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support> to the debug and release entry for ARM64:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
and WindowsSDKDesktopARMSupport for 32Bit ARM.
Save changes, load the project again and now compilation works fine:
The 15.9 Update for VS2017, adds official ARM64 support (only for UWP), here the commandline to open ARM64 dev prompt is:
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64_arm
32 Bit Arm commandline is:
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" x86_arm

Specific the Visual C++ compiler in cmake [duplicate]

After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (PROJECT):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:4 (PROJECT):
No CMAKE_CXX_COMPILER could be found.
I went searching for cl.exe in the Visual Studio folder,C:\Program Files\Microsoft Visual Studio 14.0, and could not find it.
How do I set up CMake to work on Windows with Visual Studio 2015?
I have found the solution. While the Visual Studio IDE installed successfully it did not install any build tools and therefore did not install the C++ compiler.
By attempting to manually create a C++ project in the Visual Studio 2015 GUI I was able to prompt it to download the C++ packages. CMake was then able to find the compiler without any difficulty.
Here is the solution that worked for me:
Open Visual Studio command prompt tool (as an administrator). On windows 10 it might be called 'Developer command prompt'.
Navigate to where you have the CMake executable
Run Cmake.exe
Proceed as usual to select build and source folder
Select the appropriate Visual Studio compiler and hit the configure button
Hopefully it should run without problems.
I looked in CMakeError.log file and found an error about cannot run 'rc.exe'
I searched and found this answer to copy RC.Exe and RcDll.Dll from the Microsoft SDKs bin to the VC bin, and then CMake worked.
Edit: The top answer to another question suggests that it's a PATH issue, so it could be enough to ensure the Microsoft SDK bin is in your PATH.
Those stumbling with this on Visual Studio 2017: there is a feature related to CMake that needs to be selected and installed together with the relevant compiler toolsets. See the screenshot below.
Make sure you are using the correct version of Visual Studio in the generator. I had incorrectly selected Visual Studio 15 when Visual Studio 14 installed.
If none of the above solutions worked, then stop and do a sanity check.
I got burned using the wrong -G <config> string and it gave me this misleading error.
First, run from the VS Command Prompt not the regular command prompt. You can find it in
Start Menu -> Visual Studio 2015 -> MSBuild Command Prompt for VS2015 This sets up all the correct paths to VS tools, etc.
Now see what generators are available from cmake...
cmake -help
...<snip>...
The following generators are available on this platform:
Visual Studio 15 [arch] = Generates Visual Studio 15 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
...
Then chose the appropriate string with the [arch] added.
mkdir _build
cd _build
cmake .. -G "Visual Studio 15 Win64"
Running cmake in a subdirectory makes it easier to do a 'clean' since you can just delete everything in that directory.
I upgraded to Visual Studio 15 but wasn't paying attention and was trying to generate for 2012.
For me, I checked the CMakeError.log file and found:
[...] error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
This is despite using Visual Studio 2017 on Windows 7. So it appears that CMake is trying to build its detection project with the Windows 8.1 SDK.
I used the Visual Studio installer to add that component and now CMake is happy as a clam.
Menu → Visual Studio 2015 → MSBuild Command Prompt for Visual Studio 2015. Then CMake can find cl.exe.
set PATH="c:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\";%PATH%
Change the upper path to where your Windows SDK is installed.
CMake can find rc.exe.
cd to the path of CMakeLists.txt and do:
md .build
cd .build
cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release
cmake --build .
The param after -G should be fetched by CMake. Use --help; you may or may not have the generator.
I ran into the same issue and fixed it by relaunching the Visual Studio Install and checking the following option:
Windows and Web Development / Universal Windows App Development Tools / Windows 10 SDK
It contains the standard C++ headers used in most applications and therefore it is often necessary to install it as well.
I had this issue under Windows 10 when using Visual Studio 2015 Professional, while Visual Studio 2015 Express worked! Under Windows 7, both Visual Studio versions used to work.
New projects created from the Visual Studio 2015 Professional IDE successfully compile, but CMake would fail to find the compiler reporting:
The C compiler identification is unknown
The CXX compiler identification is unknown
I upgraded CMake from 3.4.1 to 3.11.4, and now the problem is gone.
If you are on Visual Studio 2017 you need at least CMake 3.8!
I had a similar problem with the Visual Studio 2017 project generated through CMake. Some of the packages were missing while installing Visual Studio in Desktop development with C++. See snapshot:
Visual Studio 2017 Packages:
Also, upgrade CMake to the latest version.
Checking CMakeErrors.log in CMakeFiles returned:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140_xp\Toolset.targets(36,5): warning MSB8003: Could not find WindowsSdkDir_71A variable from the
registry. TargetFrameworkVersion or PlatformToolset may be set to an
invalid version number.
The error means that the build tools for XP (v140_xp) are not installed. To fix it I installed the proper feature in Visual Studio 2019 installer under Individual Components tab:
I was running old cmake version (i.e. 3.8) and I'm using visual studio 16 - 2019. After updating my cmake version, it did detect the compiler.
In my case there was an environment variable set which was the reason for this error.
The problem was solved after deleting cxx_flags from the environment variables.
I got this problem with CMake 3.12.1, after an update of Visual Studio 2017. I simply re-ran CMake and it worked.
In my case I could see in the CMakeError.log that CMake could not find the Windows SDK (MSB8003: Could not find WindowsSDKDir variable from the registry).
The version can be specified on the commandline on the first CMake run using:
-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=
I got further after setting that, but I hit more issues later (so I assume my environment is messed up somehow), but maybe it will help someone with this issue.
A couple of tips:
Try to set the path manually by checking 'advanced' and modifying CMAKE_LINKER and CMAKE_MAKE_PROGRAM
Delete the cache - in the CMake with GUI go to:
File → Delete Cache.
My problem was a combination of previously stated: I have set the compiler version to 15 instead of 14 and when corrected, I had to delete the cache.
I also started the Visual Studio command prompt as an administrator and from there I ran the cmake-gui.exe
Then everything worked as it was supposed to.
In my case the issue was that the parent project, which is including googletest via
add_subdirectory(gtest_dir)
was defined as
PROJECT( projname CXX )
Somehow, CMake does not recognize
PROJECT(sub_project_name CXX C)
since the C compiler is not set in the parent.
I solved the issue by using
PROJECT( projname CXX C)
in my main CMakeLists.txt file.
This might be another solution for those with the latest Windows 10 creator version:
Stack Overflow post Fatal error LNK1104: cannot open file 'gdi32.lib'
None of the previous solutions worked for me. However I noticed that although I installed Visual Studio version 15 (not to be confused with Visual Studio 2015) the directory created on my computer was for Visual Studio 14.
When I specified Visual Studio 14 when I pressed the configuration button it worked.
i found this sollution at stackoverflow and i work for me although not working other sollutions
if you have a windows 10 OS, doing the following steps will fix the problem:
1) go to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin
2) then copy RC.exe and RcDll from this file
3) go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin and paste the two files you have copied into it.
thats all i hope it is helpful...
Look in the Cmakelists.txt if you find ARM you need to install C++ for ARM and as well vcvarsall.bat use for ARM bin folder.
It's these packages:
C++ Universal Windows Platform for ARM64 "Not Required"
Visual C++ Compilers and libraries for ARM "Not Required"
Visual C++ Compilers and libraries for ARM64 "Very Likely Required"
Required for finding Threads on ARM
enable_language(C)
enable_language(CXX)
Then the problems might disappear:
No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.
If above does not resolve your problem?
Optionally you can remove the options C and CXX in cmakelists.txt by setting # infront of where the enable_language(C) is. And avoid Android ARM processor compilation.
Resolved by adding the missing component
Modify->continue add as follow
I had a related problem: the Visual C++ generators were not even on the list when running cmake --help.
I ran where cmake in console and found that cygwin also provides its own cmake.exe file, which was being used. Changing the order of directories in PATH fixed the problem.
I had this issue with CMake GUI and the VS 21019 Community Edition. I think I may have installed CMake before Visual Studio - certainly after I updated CMake 3.15.2 to 3.15.3 the problem went away.
Check name folder too long or not.
This question is old, but none of the solutions here were working for me. I'm using Visual Studio 2019, and in my case, C++ compilation was working but just broke one day.
However, I noticed that there was an update ready to be installed in the Visual Studio Installer.
After installing that update, rebooting my computer, and relaunching Visual Studio, all of the C++ CMake problems disappeared. I'm not quite sure why this fixed it, and I can only speculate, but I can only assume that one of two things occurred. Either installing that update fixed a broken installation, or the update was quietly downloaded and prepared in the background, breaking things in the process.
I met the same issue in VSCode Cmake extension, i solve it by check following two options:
In the end, click [Scan for kits]
cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_C_COMPILER:FILEPATH=C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe" -Hc:/code -Bc:/code/build -G "MinGW Makefiles"

I cannot run any of the sample applications that come with directx

I downloaded the latest DirectX, I have Windows 7 and Visual Studio 2012. When I open any of the sln files from the samples folder and try to build them, I get the same error "main entry point not found".
For example:
"Error 6 error X3501: 'main': entrypoint not found C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Direct3D\ShadowMap\FXC ShadowMap"
What is wrong?
Visual Studio 2012 by default is trying to compile the ".fx" shader code. You need to turn this off if you want to use a downloaded SDK (the most current version of the DirectX SDK is now part of the Windows SDK).
The (old) DirectX SDK samples use the run-time HLSL compiler (via functions like D3DX11CompileFromFile()). ".fx" files are now by default compiled by Visual Studio 2012.
You need to select any ".fx" or ".hlsl" shader program files in VS2012 and set them to "exclude from build" (right-click the ".fx" file and select "Properties" > "General" > "Exclude from build" > "Yes").

Resources