Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

64 bit - LNK1158 cannot run rc.exe x64 Visual Studio

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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)VCin but in the $(VSInstallDir)VCinx86_amd64 folder.

Thus, the solution to my problem was to copy rc.exe and rcdll.dll from the C:Program Files (x86)Windows Kits8.1inx86 folder to the $(VSInstallDir)VCinx86_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)VCin 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)VCin folder to the $(VSInstallDir)VCinx86_amd64 folder.

Once I did that, my project built and ran.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...