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)
asked Feb 5, 2016 at 3:49
3
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)VCbin but in the $(VSInstallDir)VCbinx86_amd64 folder.
Thus, the solution to my problem was to copy rc.exe and rcdll.dll from the C:Program Files (x86)Windows Kits8.1binx86 folder to the $(VSInstallDir)VCbinx86_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)VCbin 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)VCbin folder to the $(VSInstallDir)VCbinx86_amd64 folder.
Once I did that, my project built and ran.
answered Feb 6, 2016 at 18:13
gboygboy
6431 gold badge6 silver badges13 bronze badges
1
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 Kits10bin10.0.17134.0×64
and pasted into visual studio installation folder
C:Program Files (x86)Microsoft Visual Studio 14.0VCbin
successfully generated the code.
answered Sep 30, 2018 at 16:49
KhanKhan
1,21411 silver badges11 bronze badges
2
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
answered Aug 30, 2020 at 18:28
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 Kits10bin<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.
answered May 21, 2022 at 2:36
Timothy C. QuinnTimothy C. Quinn
3,4211 gold badge32 silver badges42 bronze badges
Пытаюсь запустить обычный проект
main.cpp
C++ | ||
|
hw.pro
Код
TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt SOURCES += main.cpp
Установил отладчик для MSVC2015_64bit C:Program Files (x86)Windows Kits10Debuggersx64cdb.exe
До этого отладчик не работал, но приложения компилировались. Подскажите в чем проблема и как её решить
Добавлено через 6 минут
Вывод в консоли сборки:
Код
16:30:47: Выполняются этапы для проекта hw... 16:30:47: Запускается: «C:Qt5.8msvc2015_64binqmake.exe» D:ProgramminGC++Qthwhw.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug" Info: creating stash file D:ProgramminGC++Qthw.qmake.stash 16:30:48: Процесс «C:Qt5.8msvc2015_64binqmake.exe» завершился успешно. 16:30:48: Запускается: «C:QtToolsQtCreatorbinjom.exe» qmake_all jom 1.1.2 - empower your cores 16:30:48: Процесс «C:QtToolsQtCreatorbinjom.exe» завершился успешно. 16:30:48: Запускается: «C:QtToolsQtCreatorbinjom.exe» C:QtToolsQtCreatorbinjom.exe -f Makefile.Debug cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebughw.vc.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -I. -IC:Qt5.8msvc2015_64mkspecswin32-msvc2015 -Fodebug @C:UsersKnstnAppDataLocalTempmain.obj.4040.16.jom main.cpp link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debughw.exe @C:UsersKnstnAppDataLocalTemphw.exe.4040.1797.jom LINK : fatal error LNK1158: не удается запустить "rc.exe" jom: D:ProgramminGC++QthwMakefile.Debug [debughw.exe] Error 1158 jom: D:ProgramminGC++QthwMakefile [debug] Error 2 16:30:50: Процесс «C:QtToolsQtCreatorbinjom.exe» завершился с кодом 2. Ошибка при сборке/установке проекта hw (комплект: Desktop Qt 5.8.0 MSVC2015_64bit) Во время выполнения этапа «Сборка» 16:30:50: Прошло времени: 00:03.
__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь
This topic has been deleted. Only users with topic management privileges can see it.
This error occurs after I installed Visual Studio 2017 and changed graphics card and its driver. Now whenever I clicked the «build» icon (the hammer) in Qt Creator, I will receive an error message «NK1158: cannot run ‘rc.exe'». It looks like that this message is from Visual Studio so I reinstalled VS2015, VS2017, Windows SDK and Qt, but the same problem persists. How to solve this problem, then?
Some info about my computer:
- Windows 10 1803
- VS2015 Update 3 version 14.0.25431.01
- Visual Studio 2017 version 15.7.1
- Qt 5.10.1
If you need any other info, please let me know. Thank you for help.
hi, @zzzhhhzzzhhh
pleasemake sure, that the WindowsKit bin folder is part of your Build Environment
i had this issue a couple of month back, that the windows kit was no longer automatically found and I had to add it manually
Yes, that’s the problem. I added «C:Program Files (x86)Windows Kits10bin10.0.17134.0×64» into the path variable and now Qt builds correctly. Thank you very much for your help!
@zzzhhhzzzhhh if your issue is solved, please don’t forget to mark your post as such. Thanks.
@J-Hilk thank you for finding the fix. I was experiencing the same problem after installing Qt Creator 4.6.2 in Windows and somehow msvc2017 worked fine although msvc2015 failed to find rc.exe.
Having said that, is there a way to automatically configure the compiler to include the right path? Your fix does the trick, but I’m assuming that it requires to tweak each project each time that we intend to do a build with msvc2015.
hi @rmam ,
you’re welcome
Have a look at this topic
QtCreator Build Environment Config File
In there @aha_1980 had the correct idea/knowledge in how to modify your kits to automatically add folders to your build environment.
But, you’ll still have to do it once for each installed Kit.
Greetings.
I know this is old but the real reason for the missing rc.exe is a bug in Microsoft SDKs path installation.
Here is a «cleaner» fix : https://stackoverflow.com/questions/43847542/rc-exe-no-longer-found-in-vs-2015-command-prompt
Hello everyone,
I have the same issue, but I can’t find the Build Environment settings in Qt5, can you show me where to find it?
Thanks in advance
@kamalberahal You mean in QtCreator not Qt5 I guess?
On the left side click on «Projects», select the Kit you’re using and go to Build.
Yes sorry that’s what I meant. Thanks a lot, I have found ir
Ya, for me it was already in my path. My problem was that I had VS2017 installed, but the qt is by default meant to build for the 2015 version. So just change the build options to the VS2017x64 version.
@stoplight said in LNK1158: cannot run ‘rc.exe’:
but the qt is by default meant to build for the 2015 version
Newer Qt versions are available for VS2017 as well.
This post is deleted!
I cannot find Build Environment settings , can you send me photo please, where I can find it
Thank you
@Ripegas Open your project in QtCreator. On the left side click on «Projects», then under Build & Run» select the Kit you’re using and then «Build». Now, at the bottom you will see «Build Environment»…
@jsulm Thank you, I have found it
The problem is rc.exe is not in the path or is not in the path property within vcproj generated by the python script (pretty_vcproj.py) of node-gyp or in the path of the system. I’ve explained within this issue comment;
1 — Printing The Command and Arguments on build.js
I have just check out the code, node-gyp has build.js and this link error is coming from doBuild() method which located in build.js. My aim is to print out the exact command with parameters.
I’ve found the runtime files of node-gyp is located at: C:Users<user-name>AppDataRoamingnpmnode_modulesnpmnode_modulesnode-gyplib
Thus, I’ve just added this console.log call at the beginning;
...
function doBuild () {
console.log("tDebug: #doBuild() is called!");
And in order to print out which exact method is called to do the build via c++ compiler, I’ve added these console.log calls;
//...
console.log("tDebug: Command : " + command);
console.log("tDebug: Arguments : " + argv);
var proc = gyp.spawn(command, argv)
proc.on('exit', onExit)
As a result, I have this output from the node run compile
command;
C:UsersLeventDesktopnodestackLevcpp_addon>npm run compile
> cpp_addon@1.0.0 compile C:UsersLeventDesktopnodestackLevcpp_addon
> node-gyp rebuild
C:UsersLeventDesktopnodestackLevcpp_addon>if not defined npm_config_node_gyp (node "C:UsersLeventAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin\....node_modulesnode-gypbinnode-gyp.js" rebuild ) else (node "C:UsersLeventAppDataRoamingnpmnode_modulesnpmnode_modulesnode-gypbinnode-gyp.js" rebuild )
Debug: #doBuild() is called!
Debug: Command : C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMSBuild.exe
Debug: Arguments : build/binding.sln,/clp:Verbosity=minimal,/nologo,/p:Configuration=Release;Platform=x64
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
main.cpp
win_delay_load_hook.cc
Creating library C:UsersLeventDesktopnodestackLevcpp_addonbuildReleaseaddon.lib and object C:UsersLeventDesktopnodestackLevcpp_addonbuildRelease
addon.exp
Generating code
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe' [C:UsersLeventDesktopnodestackLevcpp_addonbuildaddon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:UsersLeventAppDataRoamingnpmnode_modulesnpmnode_modulesnode-gyplibbuild.js:266:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Levent\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:UsersLeventDesktopnodestackLevcpp_addon
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cpp_addon@1.0.0 compile: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cpp_addon@1.0.0 compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersLeventAppDataRoamingnpm-cache_logs2018-09-19T13_40_00_412Z-debug.log
As it can be seen in the command output, the console.log for the debug purpose written as below;
Debug: #doBuild() is called!
Debug: Command : C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMSBuild.exe
Debug: Arguments : build/binding.sln,/clp:Verbosity=minimal,/nologo,/p:Configuration=Release;Platform=x64
2 — Applying the MSBuild command with arguments
Thus, the command executed by node-gyp (using the os package) is as below;
"C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMSBuild.exe" build/binding.sln /clp:Verbosity=minimal /nologo /p:Configuration=Release;Platform=x64
Then I execute the same command in order to see if is exactly the same output or not;
C:UsersLeventDesktopnodestackLevcpp_addon>"C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMSBuild.exe" build/binding.sln /clp:Verbosity=minimal /nologo /p:Configuration=Release;Platform=x64
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Creating library C:UsersLeventDesktopnodestackLevcpp_addonbuildReleaseaddon.lib and object C:UsersLeventDesktopnodestackLevcpp_addonbuildRelease
addon.exp
Generating code
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe' [C:UsersLeventDesktopnodestackLevcpp_addonbuildaddon.vcxproj]
3 — Locating the directory of rc.exe
I’ve checked out & searched a little bit and I have found the rc.exe in following location;
C:Program Files (x86)Windows Kits10bin10.0.17134.0x86
So the problem is, rc.exe is not accessible because it is not on the path.
4 — Updating the vcxproj file to fix the problem
I’ve checked out the vcxproj file of the project, and find out this property;
<Project>
//...
<PropertyGroup>
<ExecutablePath>
// here
</ExecutablePath>
</PropertyGroup>
</Project>
Previously it was like this;
<PropertyGroup>
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)..bin;$(MSBuildProjectDirectory)..bin</ExecutablePath>
Then I’ve added the location of rc.exe as below;
<PropertyGroup>
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)..bin;$(MSBuildProjectDirectory)..bin;"C:Program Files (x86)Windows Kits10bin10.0.17134.0x86"</ExecutablePath>
I’ve applied the MSBuild command above and it worked;
C:UsersLeventDesktopnodestackLevcpp_addon>"C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMSBuild.exe" build/binding.sln /clp:Verbosity=minimal /nologo /p:Configuration=Release;Platform=x64
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Creating library C:UsersLeventDesktopnodestackLevcpp_addonbuildReleaseaddon.lib and object C:UsersLeventDesktopnodestackLev
cpp_addonbuildReleaseaddon.exp
Generating code
Finished generating code
addon.vcxproj -> C:UsersLeventDesktopnodestackLevcpp_addonbuildRelease\addon.node
5 — Solution Ideas
The practical solution is to add rc.exe location to the path however, I’m not sure if this is the best practice or not. I’ve find out that there is a module located on «C:UsersLeventAppDataRoamingnpmnode_modulesnpmnode_modulesnode-gypgyptools» that has the name «pretty_vcproj.py«. Maybe the path of rc.exe can be automatically found and added via this python script.
содержание
1. Решите Неизвестный тип отладчика «Нет двигателя» во время отладки qt
2. Qt: ошибка lnk1158 не удается запустить rc.exe
3. О решении проблемы «Ошибка: не удается открыть … main.obj.10836.32.jom для записи» при использовании компилятора msvc при компиляции Qt
Первая яма при обращении к qt: не удалось создать каталог «E: oysl QT Ошибка в» Util.asciify («build-untitle
1. Решите Неизвестный тип отладчика «Нет двигателя» во время отладки qt
Мой метод: я обнаружил, что: я не компилировал и запускал его напрямую, он сообщит об ошибке, подобной этой; если я сначала скомпилирую, а затем запустил, ошибки не будет. Надеюсь, я смогу вам помочь.
Вот другие методы:
Сначала перейдите на официальный сайт Microsoft, чтобы загрузить cdb, по адресу: http://msdn.microsoft.com/zh-cn/library/windows/hardware/ff551063
Щелкните ссылку, показанную в поле на рисунке, чтобы перейти на страницу загрузки.
Затем запустите загруженный sdksetup.exe, оставьте предыдущие параметры по умолчанию до интерфейса, показанного на рисунке ниже, удалите избыточные параметры и просто оставьте «Инструменты отладки для Windows».
По умолчанию отладчик будет установлен в: C: Program Files (x86) Windows Kits 8.1 Debuggers
После завершения установки вы можете найти отладчик cdb.exe в каталоге установки.
Затем вам нужно клонировать конфигурацию Qt Kits, а затем выбрать соответствующую версию cdb из раскрывающегося списка, который разделен на 32-битную и 64-битную, как показано на рисунке ниже.
2. Qt: ошибка lnk1158 не удается запустить rc.exe
Когда я запускаю программу Qt сегодня, «ошибка lnk1158 не может запустить rc.exe» в режиме выпуска.
Версия Qt: Qt 5.7.0 MSVC2015_64bit
Операционная система: win10 64bit
Решение:
1.
Скопируйте rc.exe и rcdll.dll в каталог C: Program Files (x86) Windows Kits 10 bin 10.0.15063.0 x64 в
C:Program Files (x86)Microsoft Visual Studio 14.0VCbinamd64
Если версия qt 32-битная:
Скопируйте rc.exe и rcdll.dll в каталог C: Program Files (x86) Windows Kits 10 bin 10.0.15063.0 x86 в
C:Program Files (x86)Microsoft Visual Studio 14.0VCbin
или это могло быть:
2.
Найдите путь, по которому размещен rc.exe, например C: Program Files (x86) Windows Kits 10 bin 10.0.15063.0 x64
Затем добавьте его в переменную окружения PATH, перезапустите Qt!
Если после установки переменных среды выдается сообщение об ошибке, необходимо перезагрузить компьютер.
3. О решении проблемы «Ошибка: не удается открыть … main.obj.10836.32.jom для записи» при использовании компилятора msvc при компиляции Qt
Ошибка: «Ошибка: не удается открыть C: Users Dí? Ú ?? a AppData Local Temp main.obj.10836.32.jom для записи»
Как показано ниже:
Решение (Примечание. Эта проблема не имеет ничего общего с тем, указан ли путь имени пользователя на китайском языке)
Нажмите «Проект» -> «Управление наборами …» -> «Сводка» -> «Снимите флажок« Использовать jom вместо nmake », как показано ниже:
Первая яма при обращении к qt: не удалось создать каталог «E: oysl QT Ошибка в» Util.asciify («build-untitle
: Could not create directory «E:oyslQTError in » Util.asciify(«build-untitled-Desktop_Qt_5_6_2_MSVC2015_64bit-Debug»)»: TypeError: Property ‘asciify’ of object Core::Internal::UtilsJsExtension(0x251a700) is not a function»
Error while building/deploying project untitled (kit: Desktop Qt 5.6.2 MSVC2015 64bit)
When executing step «qmake»
Откройте проект слева от qt, вы можете увидеть путь компиляции этого проекта, изменить его на абсолютный путь или установить соответствующий относительный путь.
Эм«, все не могут найти это, думаю еще вырезал картинку, тоже долго искал …