Darknet: fatal error LNK1104: cannot open file 'ucrtd.lib'

Created on 14 Mar 2019  路  6Comments  路  Source: AlexeyAB/darknet

When running build.ps1 I get the following error from cmake and it fails to detect the compiler. The error is that when building the compiler test the linker fails to find ucrtd.lib. However, I can pull the linker command out of the error log and it runs fine. Any ideas?

The failed command is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib" /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\software\vcpkg\installed\x64-windows\debug\lib\*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj

which I can paste into PS and run without errors.

The full error log is:

`Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:

The output was:
1
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/14/2019 1:37:33 PM.
Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
VcpkgTripletSelection:
Using triplet "x64-windows" from "C:\software\vcpkg\installed\x64-windows\"
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\CL.exe /c /I"C:\software\vcpkg\installed\x64-windows\include" /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc141.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib" /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\software\vcpkg\installed\x64-windows\debug\lib*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.22

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:

The output was:
1
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/14/2019 1:37:35 PM.
Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
VcpkgTripletSelection:
Using triplet "x64-windows" from "C:\software\vcpkg\installed\x64-windows\"
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\CL.exe /c /I"C:\software\vcpkg\installed\x64-windows\include" /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc141.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib" /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\software\vcpkg\installed\x64-windows\debug\lib*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.23

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:

The output was:
1
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/14/2019 1:40:02 PM.
Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
VcpkgTripletSelection:
Using triplet "x64-windows" from "C:\software\vcpkg\installed\x64-windows\"
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\CL.exe /c /I"C:\software\vcpkg\installed\x64-windows\include" /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc141.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib" /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\software\vcpkg\installed\x64-windows\debug\lib*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.24

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:

The output was:
1
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/14/2019 1:40:03 PM.
Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
VcpkgTripletSelection:
Using triplet "x64-windows" from "C:\software\vcpkg\installed\x64-windows\"
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\CL.exe /c /I"C:\software\vcpkg\installed\x64-windows\include" /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc141.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib" /LIBPATH:"C:\software\vcpkg\installed\x64-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\software\vcpkg\installed\x64-windows\debug\lib*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\software\darknet\build_win_release\CMakeFiles\3.14.0-rc4\CompilerIdC\CompilerIdC.vcxproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.23

`

Most helpful comment

Building in Release I found one small issue with the darknet project. The Additional Dependencies in the linker has a corrupt pthread line:

optimized%3BC:\software\vcpkg\installed\x64-windows\lib\pthreadVC2.lib%3Bdebug%3BC:\software\vcpkg\installed\x64-windows\debug\lib\pthreadVC2d.lib

After editing the project file and replacing with:

C:\software\vcpkg\installed\x64-windows\lib\pthreadVC2.lib;C:\software\vcpkg\installed\x64-windows\debug\lib\pthreadVC2d.lib

I was able to build the Release

All 6 comments

One other comment, vcpkg works fine and I can build pthreads and opencv[cuda] without any issues.

@charlnaya Hi,

Hi @AlexeyAB, that ps1 file fails with the same error. I'll give cmake gui a try and let you know.

hi @AlexeyAB, @charlnaya i have exactelly the same issue it try to understand why :( missing MSVS 17 sdk, or so ... I try to build the project GPU base with CUDA 10.1 and cudnn 10. I will let you know if i amable to found something or if i can manage to do it with cmake will try, if i could mange this

Hi @AlexeyAB , I tested with cmake-gui and was able to configure and generate the VS files and then build darknet in VS. I did have to edit CMAKE_TOOLCHAIN_FILE as it was not getting the VCPKG_ROOT env variable. Otherwise it seemed to work fine.

Building in Release I found one small issue with the darknet project. The Additional Dependencies in the linker has a corrupt pthread line:

optimized%3BC:\software\vcpkg\installed\x64-windows\lib\pthreadVC2.lib%3Bdebug%3BC:\software\vcpkg\installed\x64-windows\debug\lib\pthreadVC2d.lib

After editing the project file and replacing with:

C:\software\vcpkg\installed\x64-windows\lib\pthreadVC2.lib;C:\software\vcpkg\installed\x64-windows\debug\lib\pthreadVC2d.lib

I was able to build the Release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cipusha picture Cipusha  路  3Comments

hemp110 picture hemp110  路  3Comments

Yumin-Sun-00 picture Yumin-Sun-00  路  3Comments

HanSeYeong picture HanSeYeong  路  3Comments

qianyunw picture qianyunw  路  3Comments