LNK1158 cannot run rc.exe x64 Visual Studio
Asked Answered
B

4

20

I'm trying to compile a simple program in Visual Studio for a 64-bit platform. Upon trying to compile, I get the error: LINK : fatal error LNK1158: cannot run 'rc.exe'

I've been to many discussion threads where it indicates to copy rc.exe and rcdll.dll from the Windows Kits folder to the VC/bin folder. I've done this to no avail. It occurs to me that my version of Visual Studio may just not be looking in the directory I think it's looking for this rc.exe file. Is there a way to identify w/in Visual Studio which directory it's looking for this executable?

(It was suggested that this problem may be a duplicate of the question and answer provided at Cannot compile with VC++/VS2010 targeting x64: LNK1158: cannot run cvtres.exe. However, this does not seem to be the case because, there, the path was getting corrupted by some NV services that were running on the system. I am not having that problem as my full path shows up when I type echo %PATH%. That being said, that link did lead me to the correct solution, given below)

Beehive answered 5/2, 2016 at 3:49 Comment(3)
Try to turn on "Detailed" output for builds in Visual Studio options. It always helped me in cases like this.Hasbeen
Possible duplicate of Cannot compile with VC++/VS2010 targeting x64: LNK1158: cannot run cvtres.exeMachiavelli
Thanks for this guidance. It also helped with a LNK1158 error from Qt Creator. It was the same issue. I only had to move the rc.exe and rcdll.dll from the VS path to the Qt's compiler path.Unheardof
B
30

The error was indeed where I was placing the rc.exe and rcdll.dll files. Because I'm compiling to a 64-bit platform, Visual Studio is using the 64-bit 'cross-compiler' which does not reside in the $(VSInstallDir)\VC\bin but in the $(VSInstallDir)\VC\bin\x86_amd64 folder.

Thus, the solution to my problem was to copy rc.exe and rcdll.dll from the C:\Program Files (x86)\Windows Kits\8.1\bin\x86 folder to the $(VSInstallDir)\VC\bin\x86_amd64 folder.

Doing that overcame that first error.

However, upon building, a new error popped up: LNK1158: cannot run 'cvtres.exe'. In contrast to my first rc.exe error, this file actually already does reside in the $(VSInstallDir)\VC\bin folder. The problem is that the cross-compiler is looking for it in its own directory. So I just copied that file from the $(VSInstallDir)\VC\bin folder to the $(VSInstallDir)\VC\bin\x86_amd64 folder.

Once I did that, my project built and ran.

Beehive answered 6/2, 2016 at 18:13 Comment(1)
I was trying to install Scrapy when I got the first error you said above. The first part of the solution worked for me. Thanks!Trapani
W
25

i encountered this error while compiling a python code in VS2015 windows 10 copied on anaconda3.

rc.exe

rcdll.dll

from

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

and pasted into visual studio installation folder

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

successfully generated the code.

Wohlen answered 30/9, 2018 at 16:49 Comment(3)
Great. This worked for me. Had the issue when trying to install odoo requirements via pipNailhead
This worked for me when I was trying to set up MobSF via setup.bat on Windows 10Oxyacetylene
Windows Kits\10\bin\10.0.22621.0\x64 checking in here; I also had to copy over ServicingCommon.dll, as rc.exe complained that it couldn't find that file otherwise.Plurality
C
0

definitely simpler to set an env variable to the folder containing the missing files, instead of copying.

set WINKITS="C:\\Program Files (x86)\\Windows Kits\\8.0\\bin\\x86"
set PATH=%WINKITS%;%PATH%

Change 8.0 with the version of your own Windows Kits

Coakley answered 30/8, 2020 at 18:28 Comment(0)
F
0

I encountered this while trying to build mod_wsgi python module. The cleanest solution is to first find the correct rc.exe and then add that folder to your PATH environment variable. Once you restart your cmd, it should resolve the issue.

As others have mentioned, rc.exe can be found under: C:\Program Files (x86)\Windows Kits\10\bin\<version>\x64

Its unlikely that this file is changing between versions but it would be important to choose x64 if you are compiling for 64 bit and x86 for 32 bit.

Fauces answered 21/5, 2022 at 2:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.