154

I've searched online and couldn't find anything that resembled to my issue.

I created an empty C++ project and added a main.cpp with a return and I can't get it to build. Here is the message I receive :

1>------ Build started: Project: Project1, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1158: cannot run 'rc.exe'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Is there somewhere within VS2012 where I can specify where to find this executable? I have installed the Windows 7 SDK and I have this executable at:

C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin

I come from Code::Blocks and using mingw-gcc without any trouble, but lately I've been needing VS for managed implementations so I hope someone has an idea.

Patrick.SE
  • 4,444
  • 5
  • 34
  • 44
  • FYI - broken in Visual Studio 2013 Professional too :( – gbjbaanb Oct 18 '13 at 12:19
  • but it looks like the issue is the path to the windows SDK dir (or Windows Kits, whatever they are calling them this week). The $(WindowsSdkDir) var is not set to the WindowsKits directory, is set to the WindowsSDK dir instead which has 'minimal' contents. – gbjbaanb Oct 18 '13 at 15:53
  • 5
    Good solution for similar VS2015 issues, caused by VS2017: https://stackoverflow.com/a/45319119/508431 – Isaiah Norton Feb 18 '18 at 21:03
  • 1
    be sure to read **THIS CRITICAL QA** https://stackoverflow.com/questions/43847542 – Fattie Dec 14 '18 at 13:15

28 Answers28

277

Found this on Google... I would assume that in your case you would copy rc.exe and rcdll.dll to visual studio 2012\vc\bin or wherever you have it installed:

Part 2: FIX LINK : fatal error LNK1158: cannot run ‘rc.exe’

Add this to your PATH environment variables:

C:\Program Files (x86)\Windows Kits\8.0\bin\x86

Copy these files:

rc.exe
rcdll.dll

From

C:\Program Files (x86)\Windows Kits\8.0\bin\x86

To

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin

Or I also found this:
Microsoft left a few things out of their MSVT package. Since no one knows whether they were left out by mistake or for license reasons, no one with MSVC is too interested in giving them out. A few Google searches turn up some tricky sources. Fortunately, Microsoft has finally wised up and solved this problem and many more.

http://msdn.microsoft.com/vstudio/express/support/faq/default.aspx#pricing

http://msdn.microsoft.com/vstudio/express/support/install/

A good amount of MSVT missing files are there but the missing SDK files aren't.

and this:
I had the same problem which I solved by doing this:

  1. Installing the Microsoft .Net Framework 2.0
  2. Adding the path of the .NET Framework files (for me "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727") to Global compiler settings > Programs > Additional Paths within Code::Blocks.

Now I can build and link resource files without errors.

Taylor Lopez
  • 813
  • 1
  • 8
  • 28
Kat Cox
  • 3,469
  • 2
  • 17
  • 29
  • 6
    Thanks, it was a simple manner of copying the rc executables from the SDK bin to the VS bin. – Patrick.SE Jan 17 '13 at 15:20
  • 1
    Well, most of this answer was quotes... so just to clarify "I had the same problem which I solved by doing this:" is not me, but something I found posted – Kat Cox Jul 14 '15 at 20:43
  • 1
    Question: why do you use the x86 rc.exe and rcdll.dll files, rather than the x64 versions? – Carl Jan 23 '18 at 17:10
  • 1
    Well, I just copied and pasted the answers I found... but you would use the x86 on a 32bit install (which you might have even on a 64bit system) and you would use the x64 on a 64bit install... guess it depends on which version of the file it says you are supposed to have – Kat Cox Jan 27 '18 at 09:37
  • 5
    I'm at `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64` and ran commands: `copy "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\rc.exe"` and `copy "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\rcdll.dll"` to fix this in Visual Studio 2015 – Jari Turkia Feb 22 '18 at 15:33
  • This solution worked properly for fixing my problem when trying to install the `statsmodels` library in Python 3.5.2. – abautista Apr 19 '18 at 19:56
  • "A good amount of MSVT missing files are there but the missing SDK files aren't." The irony... Microsoft broke all their links a few years ago :( – Kevin Jul 05 '18 at 01:23
  • This solution is the one that fixes the issue with pyscard also know as smartcard library for Python. – innicoder Mar 26 '19 at 19:33
  • No way, man!!! This MS is really amateur sometimes... Thanks a lot! It works for me. I was trying to install Python's twisted lib. – SnowBG Jul 23 '19 at 11:56
  • Messing around with PATH is a bit dangerous - you can get unpredicted results. Besides, what if you want x64 tools? Change PATH again? – Artyom Chirkov Oct 29 '19 at 08:12
  • 2
    I ran into this problem while installing PYANGBIND and solved it by copying rc and rcdll from `C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64` and pasting onto `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64` . – Aneesh Damodaran May 27 '21 at 02:46
66

We hit this issue with our CMake/Visual Studio 2015 builds after also installing VS2017 on the machine. The correct solution in our case is to specify the Window Kit version (8.1) to the Visual Studio Command Prompt - otherwise you get the Windows 10 Kit by default which doesn't include rc.exe in the bin directory.

e.g. Start Menu->Visual Studio 2015->VS2015 x64 Native Tools Command Prompt

%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 8.1

Note the 8.1 option on the end

MattAU
  • 845
  • 8
  • 13
  • 5
    I suppose this is the correct way to solve this problem. – jagttt Sep 25 '17 at 14:39
  • 3
    Although I'm in the same situation (Win10 with VS2015 AND VS2017 also installed), it didn't work for me. The only thing that fixed it for me was to manually add "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin" (the last SDK version to contain rc.exe) to the PATH ! – Scylardor Feb 17 '18 at 23:15
  • @Scylardor - the path you used was for the 7.1 SDK. Do you have the 8.1 SDK installed under C:\Program Files (x86)\Microsoft SDKs\Windows? It may be possible to use the same command with 7.1 on the end in your case or alternatively you might need to install the 8.1 SDK. – MattAU Feb 19 '18 at 15:53
  • I created a batch file with `call C:\\(....)\vcvarsall.bat" amd64 8.1` and `start cmake-gui`, works like a charm – Marius Mar 12 '18 at 08:46
  • Thanks, had the exact same setup (side-by-side VS) and this is *much* cleaner than copying files around! – E. Moffat Sep 13 '18 at 20:15
35

From what I have found, if you have a windows 7 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 12.0\VC\bin and paste the two files you have copied into it.

I had the same problem, and the above posted solution did not work. My solution was derived from it, and it worked for me, if the ones above do not work you can give this one a try.

Potato
  • 628
  • 5
  • 8
18

This rc.exe error can occur if the Visual C++ compiler and the Windows 10 SDK versions don't correspond to the same Visual Studio year. In general, the solution is to make sure you have on your system, and are using in the compilation, VC++ and Windows SDK for the visual studio year you are using.

For instance, if you have Visual Studio 2017 or 2019, and you installed Build Tools 2015 without selecting to install its own 2015 Windows SDK (default installation does not install it!), and are trying to use it to compile, you may run into this problem.

In my case, I already had Visual Studio 2017. When I tried to use Build Tools 2015 to compile a python library (or probably any program), this same 'rc.exe' error occurred. I read that the VS2015 14.0 C++ compiler can glitch if it tries to use the Windows 10 SDK from Visual Studio 2017.

I uninstalled Build Tools 2015, and reinstalled it, this time as a custom installation, selecting to install both visual C++ and Windows 10 SDK components. This fixed the issue.

UPDATE: I just looked at Build Tools 2015 again, and apparently there is no custom installation option anymore. If so, installing Visual Studio 2015 with C++ and Windows SDK components should also work. Edit: commenter has found the customizable build tools installer

JoseOrtiz3
  • 1,785
  • 17
  • 28
  • 2
    Thank you very much, this is indeed the proper solution. Note: I tried adding the SDK through the "Modify" command of the installer, but it got stuck. Had to reboot, uninstall, then install from scratch. – Violet Giraffe Apr 27 '18 at 11:17
  • Could anyone help clarify what was meant by "... reinstalled it [Build Tools 2015], this time as a custom installation, selecting to install both visual C++ and Windows 10 SDK components." Installed from where? As a standalone from Microsoft? – estebro Sep 26 '18 at 14:24
  • @estebro If you google "Build Tools 2015" and click the first link, you will be taken to Microsoft's download page for this standalone package. Download and install the package, however DO NOT let the package install by default if you are having the rc.exe issue. INSTEAD, select for a custom installation, and make sure to *enable* the installation of Windows SDK (its not default). – JoseOrtiz3 Sep 27 '18 at 07:46
  • 1
    This is the true, conceptually correct answer. All others are hacks that may not work; none of them did for me. – iLikeDirt Dec 14 '18 at 22:58
  • 1
    THIS OMFG! Thank you for the clear explanation. I ran into the exact same problem and the people blaming the install was such a red herring. I re-installed five times to see the same result. – Ananth Feb 22 '19 at 04:20
  • 1
    Looks like you can still get the customisable 2015 installer here: https://visualstudio.microsoft.com/vs/older-downloads/ – inkychris Sep 14 '20 at 16:50
11

In my case, I had a mix and match error between projects created in VS2015 and VS2017. In my .vcxproj file, there's this section called PropertyGroup Label="Globals">. I had a section for TargetPlatformVersion=10.0.15063.0. When I removed the TargetPlatformVersion, that solved the problem.

Sorry I can't copy and paste the block here, but stackoverflows coding format did not allow that.

Todd Rupper
  • 111
  • 1
  • 3
9

In my case, VS 2019 on Windows 10 x64, I followed mostly what it was said in the answers but pasted rc.exe and rcdll.dll from C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86 to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin, which is where link.exe is.

Sara S
  • 101
  • 1
  • 4
8

I'm on Windows 7 x64 and Visual Studio 2017. I get this error trying to compile a cython script. That's how I solved: I copied and pasted rc.exe and rcdll.dll from:

C:\Program Files (x86)\Windows Kits\8.1\bin\x86

to

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64
alfredopacino
  • 2,979
  • 9
  • 42
  • 68
  • 4
    These instructions are for 32-bit. For 64-bit, try `C:\Program Files (x86)\Windows Kits\8.1\bin\x64` to `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64`. – Contango Feb 03 '18 at 12:44
  • For us with Cython, this worked: We copied the `C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64` to `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64` to fix the Visual Studio can't build due to rc.exe error – Brandon W. King Jul 25 '20 at 19:10
4

Here is my almost similar case:
I have VC2010 working project under Win7 32bit. I make clean install of VC2013 under Win8.1 64bit After successful converting of my project from VC2010 to VC2013, during 1st compilation the following error rise:
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe'

Solution 1:
Delete whole line “<ExecutablePath Condition=”...”>...</ExecutablePath>” in element “<PropertyGroup>” in NameOfYourSolution.vcxproj file in notepad before to run VC2013
Solution 2:
Copy only two files: rc.exe and rcdll.dll from “c:\Program Files (x86)\Windows Kits\8.1\bin\x86\” to “c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\” and compilation will be successful!!
Note:
a)It is not need to touch any PATH or other Windows or VC environment variables.
b)“Platform Toolset” (Project Property Pages –> Configuration Properties –> General) will be automatic set to “Visual Studio 2013 (v120)” (not change it to “Visual Studio 2010” to be able to continue to develop your project under VC2013 concepts)

Angel T
  • 182
  • 2
  • 7
4

In my case the error was due to a bad setting in a vcxproj. The vcxproj was from a third party, so I'm not sure how it got in that state.

Specifically, for one of the platform/profile combos, the platform folder was missing from the Windows SDK bin folder:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
 <ExecutablePath>$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin\x86;

is correct, where

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
 <ExecutablePath>$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;

was incorrect. Might need to scroll to the end of the code boxes to see the difference.

Note also, that for some strange reason $(WindowsSdkDir)bin\x64; did NOT work for me. Tried to figure out why, when rc.exe definitely exists in that folder, but I gave up.

In my opinion, the solutions from previous posters that involve copying rc.exe all over the place are wrong, because your project will not work on anyone else's machine. If you fix up the paths in the project correctly, it should work on any machine with a correct installation of the Windows SDK.

Steve
  • 571
  • 5
  • 10
4

I'm on Windows 10 x64 and Visual Studio 2017. I copied and pasted rc.exe and rcdll.dll from:

C:\Program Files (x86)\Windows Kits\8.1\bin\x86

to

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64

it's works with: ( qt creator 5.7.1)

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
dodo
  • 51
  • 2
3

This might be a little outdated. But if copying the rc.exe and exdll.dll did not work, there is a chance that the windows sdk is not installed properly even if the windows sdk folder exists. You can update the sdk for win 8 in the following page: http://msdn.microsoft.com/en-US/windows/hardware/hh852363 After re-installing the sdk, the problem would get solved. Also make sure that platform toolset is set properly.

beebee
  • 280
  • 3
  • 18
3

I've encountered this issue recently. I have both VS 2015 and VS 2017 installed, Windows kits 8.1 and 10 installed.

Command prompt from VS 2017 works as expected, rc.exe is visible. In VS 2015 this is not true. Actually, vcvarsall.bat script from VS 2015 does add a path to Windows 10 kit to PATH variable, but it adds a slightly wrong path. It adds path to

"C:\Program Files (x86)\Windows Kits\10\bin\x86"

while the actual path is

"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86"

It seems that updating Windows 10 kit (or installing VS 2017) led to this issue.

So the solution is simple: just create symbolic links in "C:\Program Files (x86)\Windows Kits\10\bin" folder pointing to the corresponding folders in the underlying folder, e.g. a symbolic link "x86" for folder "10.0.17763.0\x86", "x64" for "10.0.17763.0\x64" etc.

Artyom Chirkov
  • 233
  • 1
  • 10
3

I'm on Windows 10 Pro x64, VS 19..

When trying to install mod_wsgi for apache in cmd.

C:\>python -m pip install mod_wsgi

This is the error I was getting from my command prompt.

LINK : fatal error LNK1158: cannot run 'rc.exe'

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158

I had to copy rc.exe & rcdll.dll from

C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86

and add it to

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64

result from cmd

C:\>python -m pip install mod_wsgi
Collecting mod_wsgi
Using cached mod_wsgi-4.7.1.tar.gz (498 kB)
Installing collected packages: mod-wsgi
Running setup.py install for mod-wsgi ... done
Successfully installed mod-wsgi-4.7.1

Hope this helps someone.

dynastoned
  • 61
  • 7
2

I had the same problem on VS 2013 and was able to fix it by changing the Platform Toolset.

You can find it in project settings, general.

E.g. switching Platform Toolset to VS 2010 will cause VS to use the Windows\v7.0A SDK.

You can check which SDK path is used by adding this to your prebuild event:

echo using SDK $(WindowsSdkDir)
laktak
  • 57,064
  • 17
  • 134
  • 164
  • but still this means the VS2013 doesn't support MFC apps at all. Note that the rc.exe is in the "Windows Kits" directory and not in the SDK directories any more. Useless. – gbjbaanb Feb 20 '14 at 08:54
2

I'm using Windows 7 with VS 2013 (Update 3) and Intel Parallel Studio XE Composer Edition for Fortran Windows (Update 5). Out of the box I had the same issue.

Once I fixed the missing rc.exe problem I had another issue. The linker was missing kernel32.lib.

I corrected both issues by updating the Intel Composer Options (TOOLS->Options...->Intel Composer XE->Visual Fortran->Compilers).

For the Win32 tab I added:

Executables: C:\Program Files (x86)\Windows Kits\8.0\bin\x86; (just before $(PATH))

Libraries: C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86; (at the end)

For the x64 tab I added:

Executables: C:\Program Files (x86)\Windows Kits\8.0\bin\x64; (just before $(PATH))

Libraries: C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64; (at the end)

Update...

I was also missing some SDK header files (winver.h and winapifamily.h). I added the following to the same TOOLS->Options... area.

For both the win32 and x64 tabs

Includes: C:\Program Files (x86)\Windows Kits\8.0\Include\um;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;

Jeremy Whitcher
  • 611
  • 7
  • 10
2

I just figured out one (out of the 3 in total) projects in my VS2010 (SDK7.1) solution (projects are linked in a sequential linear dependency chain), had a .rc file in the project files that was empty. Removing the empty .rc file (from the project, without deleting it) solved the "fatal error LNK1158: ... cvtres.exe" problem.

Update: The following copy fixed the problem:

xcopy "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe" "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\"

This will enable WinSDK7.1, via MSBuild, to be able to compile .rc files into the executables.

Sterge
  • 69
  • 5
  • BTW the following copy fixed the problem: xcopy "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe" "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\" This will enable WinSDK7.1, via MSBuild, to be able to compile .rc files into the executables. – Sterge Aug 17 '15 at 05:55
2

This is even easier than that with Visual Studio 2017. Follow these instructions: https://learn.microsoft.com/en-us/visualstudio/install/modify-visual-studio to modify using Microsoft Visual Studio Installer.

Once inside the Microsoft Visual Studio Installer, click modify under your installed Visual Studio package, make sure the Desktop development with C++ is checked, and the MFC and ATl support (x86 and x64), under summary.

Bluto
  • 166
  • 1
  • 15
2

My answer to this quesiton.

Modify file C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vcvarsqueryregistry.bat The content of :GetWin10SdkDir From

@REM ---------------------------------------------------------------------------
:GetWin10SdkDir

@call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1
@if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node > nul 2>&1
@if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE > nul 2>&1
@if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE > nul 2>&1
@if errorlevel 1 exit /B 1
@exit /B 0

to

@REM ---------------------------------------------------------------------------
:GetWin10SdkDir

@call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1
@if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node > nul 2>&1
@if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE > nul 2>&1
@if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE > nul 2>&1
@if errorlevel 1 exit /B 1
@setlocal enableDelayedExpansion
set HostArch=x86
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( set "HostArch=x64" )
if "%PROCESSOR_ARCHITECTURE%"=="EM64T" ( set "HostArch=x64" )
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( set "HostArch=arm64" )
if "%PROCESSOR_ARCHITECTURE%"=="arm" ( set "HostArch=arm" )
@endlocal & set PATH=%WindowsSdkDir%bin\%WindowsSDKVersion%%HostArch%;%PATH%
@exit /B 0

Modify this single place will enable the support for all Windows 10 sdk along with all build target of visual studio, including

  • VS2015 x64 ARM Cross Tools Command Prompt
  • VS2015 x64 Native Tools Command Prompt
  • VS2015 x64 x86 Cross Tools Command Prompt
  • VS2015 x86 ARM Cross Tools Command Prompt
  • VS2015 x86 Native Tools Command Prompt
  • VS2015 x86 x64 Cross Tools Command Prompt

They are all working.

lygstate
  • 564
  • 6
  • 12
2

There are a lot of answers here, but I didn't see this one, which I believe is the right way to fix this Visual Studio bug. I recently had to install Visual Studio 2015 on a system that already had Visual Studio 2017 and 2019 along with multiple versions of the Windows SDK. When building either x86 or x64/debug or release, it could not find RC.EXE. The reason is that the Project's executable path (the $(VS_ExecutablePath)) value is incorrect. For x86 and x64, it's set to

C:\Program Files (x86)\Windows Kits\10\bin\x86
C:\Program Files (x86)\Windows Kits\10\bin\x64

which appears to be correct if 10 is replaced by 8.1 but I want to use the Windows 10 SDK not the Windows 8.1 SDK.

The Windows 10 SDK executables are actually in these directories (i.e. these are the SDKs I have installed right now):

C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\arm64\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\arm64\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86\rc.exe
C:\Program Files (x86)\Windows Kits\8.1\bin\x64\rc.exe
C:\Program Files (x86)\Windows Kits\8.1\bin\x86\rc.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\RC.Exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\x64\RC.Exe

In Windows 10 SDKs, the TargetPlatformVersion is part of the path, which allows the SDK executables/include/libs to be updated for each new TargetPlatform as it's released.

Choosing an RC.EXE and copying it to a directory in the path would work but each TargetPlatformVersion SDK directory has a different RC.EXE, so you might not know which one you are using -- especially if you have multiple developers and build machines. It's best to fix it in the projects.

To fix this,

  • Select all of the affected projects with Shift-Click
  • Right-click a selected project and select Properties,
  • Select VC++ Directories on the left
  • Select Executable Directories
  • Click the pull-down at the far right and select Edit.

Double-click the top blank line and for x86/win32 projects, add this to both Debug and Release configurations:

  $(WindowsSdkDir)bin\$(TargetPlatformVersion)\x86\

For x64 projects, add this to both Debug and Release configurations:

  $(WindowsSdkDir)bin\$(TargetPlatformVersion)\x64\

Leave "Inherit from parent or project defaults" checked. The "Evaluated Value" window may appear garbled but it seems to get fixed once you save and close the property pages.

I did not have to update "Library Directories" nor "Include Directories" but they might require similar changes.

This will make a number of entries in each Visual Studio project file that look like this:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ExecutablePath>$(WindowsSdkDir_10)bin\$(TargetPlatformVersion)\x86\;$(ExecutablePath)</ExecutablePath>
  </PropertyGroup>    

The right way to fix this is by editing the property sheet for Microsoft.Cpp.Win32.user or to define your own property sheet to add this value to the inherited values, but the Visual Studio 2015 property manager seems to be buggy (2017/2019 is much better) so I found it best to just put the value directly into the projects. This also means every other developer or build machine that uses these projects will be able to build, as long as the chosen Windows 10 SDK is installed.

UweBaemayr
  • 1,861
  • 1
  • 18
  • 21
1

This can be caused by a vcxproj that originated in previous versions of Visual Studio OR changing the Platform Toolset in Configuration Properties -> General.

If so, possible Solution:

1) Go to Configuration Properties -> VC++ Directories

2) Select drop down for Executable Directories

3) Select "Inherit from parent or Project Defaults"

Gunnar
  • 339
  • 2
  • 13
1

Add to your environment variable window sdk 8.1 path

C:\Program Files (x86)\Windows Kits\8.1\bin\x64

then open Visual studio x64 Native tools command prompt and enter

vcvarsall.bat

Khan
  • 1,288
  • 12
  • 11
1

If you really need to use the SDK Windows 10 with Visual Studio 2015, you have to download an older version on sdk-archive. Newer version of the SDK changed the place of the rc executable and MSBuild of Visual Studio 2015 update 3 (latest version) can't locate it. At least the version 10.0.14393.795 of the SDK Windows is still compatible with Visual Studio 2015.

Xavier Bigand
  • 317
  • 3
  • 10
  • This could be the actual explanation to this infuriating problem. Here's yet another recent QA on the issue, for anyone googling here ........ https://stackoverflow.com/a/53804573/294884 – Fattie Dec 16 '18 at 17:11
1

Maybe project file was touched by VS2017. Then when you link the project in 2015 "LINK : fatal error LNK1158: cannot run 'rc.exe'" can brake the build.

In vcxproj try to:

1) replace:

<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> with: <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>

2) remove: <VCProjectVersion>15.0</VCProjectVersion>

3) replace: <PlatformToolset>v141</PlatformToolset> with: <PlatformToolset>v140</PlatformToolset>

user1439579
  • 131
  • 10
1

I got the OP's link error about rc.exe when trying to execute pip install inside a bash task within an Azure DevOps pipeline that I was using to build a Python package from source with C++ extensions. I was able to resolve it by adding the path to rc.exe inside the bash task just before calling pip install, like so:

PATH="/c/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64":$PATH

That was inside an Azure job that was using vmImage: 'windows-2019' for its agent; i.e., Windows Server 2019 with Visual Studio 2019.

snark
  • 2,462
  • 3
  • 32
  • 63
1

I was able to make it work for me also this way in windows

  1. Set your environment variable to point to the location of your rc.exe assuming you're using x86 version

C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86

You can easily set your environment variable using

C:> setx path "%path%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86"

  1. Restart your Qt Creator
  2. Clean and Rebuild
Peter
  • 1,124
  • 14
  • 17
0

In my case, I installed the Windows SDK 10586 via Visual Studio 2015 -> Modify, then the following paths are installed.

C:\Program Files (x86)\Windows Kits\10\bin\arm64\rc.exe

C:\Program Files (x86)\Windows Kits\10\bin\x64\rc.exe

C:\Program Files (x86)\Windows Kits\10\bin\x86\rc.exe

Community
  • 1
  • 1
0

For Visual Studio Community 2019, copying the files in the answers above (rc.exe rcdll.dll) to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\Hostx86\x86 did the trick for me.

Rahul
  • 177
  • 3
  • 9
0

"Error LNK1158 cannot run 'rc.exe" could be resulted from your project was opened by newer MS VS version. For instance, your project was created in VS 2015, then later was opened by 2017. Then later your project is opened in 2015.

To resolve this issue, open yourProjectName.vcxproj, look for WindowsTargetPlatformVersion, and change to the correct VS version

For VS 2015, it should be 8.1 for VS 2017, it should be 10.0.17763.0

Tom
  • 1