'link failed using nmake in vs2019
I generate a winrt-x64-msvc2019 console project using qmake, so the target in makefile like below:
release\onepacker.exe: D:\qt5.15.2_msvc2019_x64\lib\Qt5Gui.lib D:\qt5.15.2_msvc2019_x64\lib\Qt5Xml.lib D:\qt5.15.2_msvc2019_x64\lib\Qt5Core.lib D:\qt5.15.2_msvc2019_x64\lib\qtmain.lib $(OBJECTS)
link /NOLOGO /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /SUBSYSTEM:CONSOLE /TLBID:1 /INCREMENTAL:NO /MANIFEST:NO /OUT:..\..\build\windows\onepacker.exe @files.txt
Here are some of my qt config in qt pro file:
QT += core xml
CONFIG += c++17
CONFIG += console
CONFIG -= app_bundle
win32 {
QMAKE_LIBS -= windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib ucrt.lib vcruntime.lib
QMAKE_LIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dbghelp.lib shell32.lib
QMAKE_CXXFLAGS += -MP -GS -Gd -FC -WX-
QMAKE_LFLAGS += /SUBSYSTEM:CONSOLE /TLBID:1
QMAKE_LFLAGS -= /SUBSYSTEM:WINDOWS
QMAKE_LFLAGS -= /NODEFAULTLIB:ole32.lib /APPCONTAINER /NODEFAULTLIB:kernel32.lib
DEFINES += _CONSOLE WIN64
}
All the source files are built well, but it's failed to run the nmake command to link the target, it said the symbol __imp_RoInitialize is not fund.
D:\jenkins\workspace\XXX\src\project>nmake
Microsoft (R) 程序维护实用工具 14.29.30139.0 版
版权所有 (C) Microsoft Corporation。 保留所有权利。
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\nmake.exe" -f Makefile.Release
Microsoft (R) 程序维护实用工具 14.29.30139.0 版
版权所有 (C) Microsoft Corporation。 保留所有权利。
link /NOLOGO /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /SUBSYSTEM:CONSOLE /TLBID:1 /INCREMENTAL:NO /MANIFEST:NO /OUT:..\..\build\windows\onepacker.exe @files.txt
MSVCRT.lib(utility_app.obj) : error LNK2019: 无法解析的外部符号 __imp_RoInitialize,函数 __scrt_initialize_winrt 中引用了该符号
release\onepacker.exe : fatal error LNK1120: 1 个无法解析的外部命令
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.EXE"”: 返回代码“0x460”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\nmake.exe"”: 返回代码“0x2”
Stop.
D:\jenkins\workspace\XXX\src\project>
But it's passed if I run the same link command directly without nmake:
D:\jenkins\workspace\XXX\src\project>link /NOLOGO /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /SUBSYSTEM:CONSOLE /TLBID:1 /INCREMENTAL:NO /MANIFEST:NO /OUT:..\..\build\windows\onepacker.exe @files.txt
D:\jenkins\workspace\XXX\src\project>
I have upgrade the vs2019 to the latest version 16.11.15, and it doesn't work too.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
