react-native-windows
react-native-windows copied to clipboard
Build failed with message LINK : fatal error LNK1104: cannot open file 'msvcprtd.lib'
Problem Description
My problem seems to be the same from this bug report, which was closed due to inactivity.
I'm following the exact step-by-step guide from here, and installed all dependencies from here.
After trying to debug the app, I get the following error (some messages were in Portuguese, so I translated here): 2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(1424,5): error MSB6006: "link.exe" exited with code 1104. 2>LINK : fatal error LNK1104: cannot open file 'msvcprtd.lib' 2>C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The task "CompileXaml" returned false, but didn't registered any error. 2>Build project ready "RNWTest.vcxproj" -- FAILURE. ========== Build: 0 successful, 2 failed, 4 updated, 0 ignored ========== ========== Build started at 09:27 and took 26,598 seconds ========== ========== Deployment: 0 successful, 0 failed, 0 ignored ========== ========== Deploy started at 09:27 and took 26,598 seconds ==========
Steps To Reproduce
- Checking all dependencies: OK
- Start a new react-native project by running
npx react-native init RNWTest --version "latest"
- Enter project folder:
cd RNWTest
- Install windows extension:
npx react-native-windows-init --overwrite
- Open Visual Studio Community 2022 and running
npx react-native autolink-windows
at the root of the project. Result as follow: - Opened my solution file:
- Set "Debug" and "x64":
- Run
yarn start
at the project directory: - Run the project inside Visual Studio Community 2022. Get these errors:
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(1424,5): error MSB6006: "link.exe"
foi encerrado com o código 1104.
2>LINK : fatal error LNK1104: não é possível abrir o arquivo 'msvcprtd.lib'
2>C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5):
error MSB4181: A tarefa "CompileXaml" retornou false, mas não registrou um erro.
2>Projeto de compilação pronto "RNWTest.vcxproj" -- FALHA.
========== Compilação: 0 bem-sucedida, 2 com falha, 4 atualizada, 0 ignorada ==========
========== Compilação começou em 08:53 e levou 48,989 segundos ==========
========== Implantação: 0 bem sucedida, 0 com falha, 0 ignorada ==========
========== Implantar começou em 08:53 e levou 48,990 segundos ==========
Full debugging log is here: https://github.com/joaotextor/RNWTest/blob/master/debugging_log.txt
- When I go to
http://localhost:8081/debugger-ui/
, this screen is shown: - When trying to run
npx react-native run-windows --logging
, this is shown in red:LINK : fatal error LNK1104: não é possível abrir o arquivo 'msvcprtd.lib' [C:\Coding\RNWTest\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj] C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: A tarefa "CompileXaml" retornou false, mas não registrou um erro. [C:\Coding\RNWTest\node_modules\re act-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
Full output for npx react-native run-windows --logging
command is here: https://github.com/joaotextor/RNWTest/blob/master/error_log.txt
Expected Results
I should be able to see my new app, and Chrome should open as stated in the "Get Started with Windows" page:
CLI version
11.3.7
Environment
npx react-native infoinfo Fetching system and libraries information...
System:
OS: Windows 10 10.0.22621
CPU: "(16) x64 AMD Ryzen 7 5800H with Radeon Graphics "
Memory: 594.47 MB / 15.35 GB
Binaries:
Node:
version: 20.7.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.19
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 10.1.0
path: ~\AppData\Roaming\npm\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.22621.0
IDEs:
Android Studio: Not Found
Visual Studio:
- 17.7.34031.279 (Visual Studio Community 2022)
Languages:
Java:
version: 11.0.18
path: C:\Program Files\Amazon Corretto\jdk11.0.18_10\bin\javac.EXE
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.5
wanted: 0.72.5
react-native-windows:
installed: 0.72.10
wanted: 0.72.10
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Target Platform Version
10.0.19041
Target Device(s)
Desktop
Visual Studio Version
Visual Studio 2022
Build Configuration
Debug
Snack, code example, screenshot, or link to a repository
Public repository: https://github.com/joaotextor/RNWTest
There doesn't seem to be anything obviously wrong from the detail you've provided (thank you, by the way). It's unable to find the VC libs and it's not clear why. We should double check the dependency script.
In the meantime can look for general assistance on this error in articles like this, although any of those that are asking you to manually add a lib path seem wrong. More just highlighting that other people have hit this outside of RNW and you might find assistance there.
Thanks for replying.
I added the path C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\lib\x64
to "Additional Library Directory" of my project.
However, I got a new error when trying to build/debug (as long as the previous error, in the top of the log):
2> Criando biblioteca C:\Coding\RNWTest\windows\x64\Debug\RNWTest\RNWTest.lib e objeto C:\Coding\RNWTest\windows\x64\Debug\RNWTest\RNWTest.exp
2>RNWTest.vcxproj -> C:\Coding\RNWTest\windows\x64\Debug\RNWTest\RNWTest.exe
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5167,5): error MSB3030: não foi possível copiar o arquivo "C:\Coding\RNWTest\node_modules\react-native-windows\build\x64\Debug\Microsoft.ReactNative\Generated Files\DevMenuControl.xaml" porque ele não foi encontrado.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5167,5): error MSB3030: não foi possível copiar o arquivo "C:\Coding\RNWTest\node_modules\react-native-windows\build\x64\Debug\Microsoft.ReactNative\Generated Files\DevMenuControl.xbf" porque ele não foi encontrado.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5167,5): error MSB3030: não foi possível copiar o arquivo "C:\Coding\RNWTest\node_modules\react-native-windows\build\x64\Debug\Microsoft.ReactNative\Generated Files\CoreAppPage.xaml" porque ele não foi encontrado.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5167,5): error MSB3030: não foi possível copiar o arquivo "C:\Coding\RNWTest\node_modules\react-native-windows\build\x64\Debug\Microsoft.ReactNative\Generated Files\CoreAppPage.xbf" porque ele não foi encontrado.
2>Projeto de compilação pronto "RNWTest.vcxproj" -- FALHA.
========== Compilação: 0 bem-sucedida, 2 com falha, 4 atualizada, 0 ignorada ==========
========== Compilação começou em 18:57 e levou 50,196 segundos ==========
========== Implantação: 0 bem sucedida, 0 com falha, 0 ignorada ==========
========== Implantar começou em 18:57 e levou 50,196 segundos ==========
In short, it throws the error MSB3030 when trying to copy the files CoreAppPage.xaml, DevMenuControl.xbf, DevMenuControl.xaml and CoreAppPage.xbf.
I checked the folder ode_modules\react-native-windows\build\x64\Debug\Microsoft.ReactNative\Generated Files\
and there are the files CoreAppPage.g.cpp, CoreAppPage.g.h, CoreAppPage.xaml.g.h and DevMenuControl with the same extensions (g.cpp; g.h; and xaml.g.h).
I have the same error, did you find a solution?