Qt 5.8 msvc 2015 compile error - visual-studio

I have installed Qt using an offline installer qt-opensource-windows-x86-msvc2015_64-5.8.0. I have visual studio community edition 2017 installed with c++ build tools. because it's compiler was incompatible with the qt version, then I installed visual c++ build tools 2015 from http://landinghub.visualstudio.com/visual-cpp-build-tools . When I try to compile a project it gives an error :-1: error: LNK1158: cannot run 'rc.exe'. Heres how my qt kit looks like,
Can someone figure out whats the mistake and how to fix it.
Thanks.

I've fixed this both on my own machine and on several co-workers machines.
It tends to happen when you have both Visual Studio 2015 and VS 2017 installed. Or more precisely, multiple versions of the Windows SDK installed. When that happens, the vcvars32.bat script (located in your Visual Studio install dir) does not correctly add the location of the resource compiler (rc.exe) to your PATH. Thus, QT Creator runs vcvars32.bat (as specified in Qt Creator under Option->Build&Run->Compilers, but the tools directory for the Windows SDK Kit isn't properly added to the PATH environment.
The simple fix is to add the appropriate version of RC.exe to your path.
Do this from the command line:
cd "c:\program files(x86)"
dir /s rc.exe
You'll get several versions (x86 and x64) and for several versions of the SDK. Add the PATH for where rc.exe lives for the version that corresponds to the SDK and build flavor to your vcvars32.bat startup script.
For example:
PATH="C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86";%PATH%
Restart Qt Creator and that should fix it.
Another fix that worked for me is to uninstall all versions of Visual Studio (and all those side installs of SQL, Windows SDKs, dev tools, etc...). Reboot. Then cleanly install VS 2017 again. Then cleanly uninstall and re-install all of Qt again. That seemed to work for me. A wonderful way to spend an afternoon.

If you update to Qt 5.9 it supports MSVC 2017. However, if you want to get it working with 5.8, I believe you might be missing the Windows SDK. You can download the SDK from Microsoft for Windows 7, 8 or 10, just get whichever version is appropriate for you.
With some googling I found a couple of other somewhat related solutions here, & here, and I've summed them up below:
If you've already got the SDK or installed it and it still doesn't work, it appears that copying rc.exe and rcdll.dll from the WindowsSDK folder to your MSVS installs \VC\bin folder may fix the problem. You might also try copying those same two files to Qt's \Qt*version number**compiler version*\bin.

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.

My newest Windows 10 SDK installation does not include rc.exe and rcdll.exe so I get LNK1158 error

I'm running Visual Studio 2015 Update 3, On Windows 10 Professional. I just installed the latest version of Windows SDK. I'm trying to compile a VC++ Console Application, very simple, but I cannot compile it because I get this error:
LINK: fatal error LNK1158: cannot run 'rc.exe'
I tried googling and I came up with this QandA but I can't find any rc.exe and rcdll.exe in my /kits/10/bin folder! Where could the problem lie?
If it matters, I installed the SDK version that came with the setup, and then installed the newest Windows 10 SDK that was on this ISO file:
17763.1.180914-1434.rs5_release_WindowsSDK.iso
I have read that rc.exe is no longer included in the Windows SDK. I had installed the oldest MSVC C++ compiler in the Visual Studio 2019 installer, but it did not contain rc.exe either. I installed the newest (which is also version 14, but with a higher minor version number!) and it contains rc.exe.

Visual Studio 2017 does not detect Windows Driver Kit installation

I already have Visual Studio 2017 professional with Desktop Development with C++ installed.
I am trying to build the Virtual Serial project found here:
https://github.com/Microsoft/Windows-driver-samples/tree/master/serial/VirtualSerial
When I try to build it, I get the error:
Severity Code Description Project File Line Suppression State
Error MSB8020 The build tools for WindowsUserModeDriver10.0 (Platform Toolset = 'WindowsUserModeDriver10.0') cannot be found. To build using the WindowsUserModeDriver10.0 build tools, please install WindowsUserModeDriver10.0 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". virtualserial C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets
I cannot find any instructions on installation aside from this website.
https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
I downloaded the WDK for Windows 10, version 1803.
I closed VS2017 and ran the installer.
When running the installer I got the message in the screenshot below, I clicked Next to continue installing
After running the installer, the project still does not build, with the same error: WindowsUserModeDriver10.0 is not installed.
What am I missing during installation? Is this the correct installer for regular VS2017 (not community edition)?
Thanks,
I know this is old, but I recently fell into this rabbit hole. What worked for me was uninstalling all of the WDKs, rebooting, and installing WDK 1803 (the wdksetup.exe program downloaded from Other WDK downloads shows version 10.0.17134.1 in properties). That WDK installer specifically calls out VS 2017 when you add the Visual Studio integration at the end of the install process.
In my situation, I installed vs2022 with SDK 19041 and WDK 19041.
After some testing, I realized that VS2022 only supports WDK 22621(so on this date). So I installed WDK 22621 and SDK 22621, and problem solved.
If you still can't find Kernel Driver Build option, try run this file C:\Program Files (x86)\Windows Kits\10\Vsix\VS2022\10.0.22621.0\WDK.vsix(WDK 19041 only has VS2019). It's a Visual Studio's extension.
According to this: https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware-winpc/windows-wdk-on-visual-studio-2017-community/fdbd2b44-e57a-4849-903d-04001205a764
WDK is not currently supported by visual studio 2017.
This is ridiculous

VCRUNTIME140.dll missing

I have a problem when trying to install apache 2.4 on my windows 10. It always shows the error that VCRUNTIME140.dll is missing. I have checked other threads and found out that installing the 2015 Visual c++ Redistributables x64/x86 always solves the problem but I have both installed and I still have this problem. Are there any other solutions?
You need to install Microsoft Visual C++ 2015 Redistributable Update 3 RC, please find the link here, choose between the 32bit or the 64bit.
Reinstall the apache 2.4 and error should gone.
I had the same issue after installing wamp on windows 10.This worked for me.
Download VCRUNTIME140.DLL
Copy the dll file to C:\Windows\System32 using administrative privileges.
Try reinstalling apache.
Download and install the proper version of Microsoft Visual C++ 2015 Redistributable Update 3 RC regarding your hardware architecture (x86 / x64). Use the link below:
Microsoft Visual C++ 2015 Redistributable Update 3 RC
On Windows 6 X64, got an error 500 on any PHP files,
installing the 2015 Visual c++ Redistributables x64 solved my problem.
I'v already had VC 2015 Redist on my PC but files were not copied into Windows\System32.
So I copied missing files directly to this folder. A thing that I should mention is since I compiled my application in X86 mode I copied them from
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86
not
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64
I know that this solution is not the ideal one, but it was a workaround for my case.
If you are using Microsoft Visual C/C++ and you have already downloaded VCRUNTIME140.DLL, Go to Project Properties->Configuration Properties-> C/C++ -> Code Generation, Set Runtime Library Multi-threaded (/MT)
Remove apache 2.4 from your pc
Download VCRUNTIME140.dll from this link
Copy VCRUNTIME140.dll file and paste it inside to Windows/System32
Finally reinstall apache and run

Compile CUDA without Visual Studio - "Cannot find compiler cl.exe in path"

I've just begun a small project in CUDA.
I need to know the following:
Is it possible to compile CUDA code without using/buying Microsoft Visual Studio?
Using Nvcc.exe I get the error "Cannot find compiler cl.exe in path".
I've tried to install a CUDA plugin for NetBeans, but it doesn't work. (with current version of NetBeans)
Platform: Windows 7
Thanks in advance.
Update
As noted in the comments, versions of the SDK after Windows 7's do not include the build tools. If you want to use Microsoft's most recent tools you have to install Visual Studio. Once installed, you can use the tools from the command-line.
At the moment the free versions are the "Community" versions, e.g. Microsoft Visual Studio Community 2015.
You can continue to develop apps for Windows 7 and earlier (and they will run on later versions of Windows) using the old SDK tools as I described before:
Original Answer
If you desperately want to avoid Visual Studio, download and install the Windows SDK. This contains (more or less) the same build tools as Visual Studio.
Then run the Windows SDK Command Prompt (which you'll find on the start menu under Microsoft Windows SDK) to set the path to point to the tools, and you are set.
Or just use Visual C++ Express.
Following the previous comments I've installed Studio Express & VS2010.
This did not solve the "cl.exe not in path" problem.
I solved the problem with the error Cannot find compiler cl.exe in path, by including
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 in PATH,
before installing Windows SDK.
This question also contains valuable information.
For some reason VS2010 & Studio Express failed to set the proper variables in path even after the execution of vsvars32.bat.
Thank you all for your valuable help.
add this options to nvcc
nvcc x.cu <other options> -ccbin "D:\Program Files\Microsoft Visual Studio 11.0\VC\bin"
i use VS2012 and my cl.exe dir is here.
You have to figure out where NVIDIA GPU Computing Toolkit is installed.
In my system it's in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" Then
"Edit Environment Variables" on Windows.
Click on New...
Variable name: NVCC
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe
Click on OK.
Use windows subsystem for linux and install ubuntu and nvcc along with gcc and g++ using the ubuntu terminal in windows (gui does not works for linux subsystem for windows). Then configure .bashrc using bash and vim/nano with a 'cd' command to your desired location as it is done in usual linux terminal (makes it easy as bash opens in system32 folder everytime). And then you can compile .cu files using nvcc over bash. As nvcc supports gcc and g++ under linux so it solves the problem. No need to sacrifice peace for switching over to linux or dealing with crappy visual studio. It worked for me.

Resources