how to compile winrt using microsoft compiler in vscode

Behe eddine 41 Reputation points
2022-04-22T16:24:23.037+00:00

cl.exe /std:c++17 /Zi /EHsc /nologo /Fe: "C:\behe\My_life\programmation\rainmeter c++ app simple ii guess\main.exe" "C:\behe\My_life\programmation\rainmeter c++ app simple ii guess\main.cpp"
main.cpp
main.obj : error LNK2019: unresolved external symbol _WINRT_IMPL_SetErrorInfo@8 referenced in function "struct winrt::hresult __cdecl winrt::impl::get_runtime_activation_factory<struct winrt::Windows::Foundation::IActivationFactory>(struct winrt::param::hstring const &,void * *)" (??$get_runtime_activation_factory@UIActivationFactory@Foundation@Adrian Röbig @winrt@@@impl@winrt@@YA?AUhresult@1@ABUhstring@Paramjeet Dahiya @1@PAPAX@Z)
main.obj : error LNK2019: unresolved external symbol _WINRT_IMPL_GetErrorInfo@8 referenced in function "struct winrt::hresult __cdecl winrt::impl::get_runtime_activation_factory<struct winrt::Windows::Foundation::IActivationFactory>(struct winrt::param::hstring const &,void * *)" (??$get_runtime_activation_factory@UIActivationFactory@Foundation@Adrian Röbig @winrt@@@impl@winrt@@YA?AUhresult@1@ABUhstring@Paramjeet Dahiya @1@PAPAX@Z)
main.obj : error LNK2019: unresolved external symbol _WINRT_IMPL_SysAllocString@4 referenced in function "public: virtual int __stdcall winrt::impl::error_info_fallback::GetDescription(wchar_t * *)" (?GetDescription@error_info_fallback@impl@winrt@@UAGHPAPA_W@Z)
main.obj : error LNK2019: unresolved external symbol _WINRT_IMPL_SysFreeString@4 referenced in function "public: static void __cdecl winrt::impl::bstr_traits::close(wchar_t *)" (?close@bstr_traits@impl@winrt@@SAXPA_W@Z)
main.obj : error LNK2019: unresolved external symbol _WINRT_IMPL_SysStringLen@4 referenced in function "public: __thiscall winrt::hresult_error::hresult_error(struct winrt::hresult,struct winrt::take_ownership_from_abi_t)" (??0hresult_error@winrt@@QAE@Uhresult@1@Utake_ownership_from_abi_t@1@@Z)
C:\behe\My_life\programmation\rainmeter c++ app simple ii guess\main.exe : fatal error LNK1120: 5 unresolved externals

this is the compiler error I get and this is main.cpp

include <fstream>

include <iostream>

include <filesystem>

include <chrono>

include <thread>

include <winrt/base.h>

include <winrt/windows.ui.viewmanagement.h>

int main (){
bool running = true;
winrt::Windows::UI::ViewManagement::UISettings Colsettings;
auto coloracc = Colsettings.GetColorValue(winrt::Windows::UI::ViewManagement::UIColorType::Accent);
std::cout << coloracc.B;
if (!std::filesystem::exists("color.inc")) {
running = false;
}
while (running)
{
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "aaaaaaaaaaa";
}
}

so yeah thanks for help I guess I can use any ide right

Universal Windows Platform (UWP)
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,721 Reputation points
    2022-04-23T07:14:33.087+00:00

    It can depend on the Windows SDK version

    With 10.0.20348.0, I don't need any additional linked lib with WinRT
    With older versions, I need to link with "WindowsApp.lib"
    In some old threads, "OleAut32.lib" was needed too

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful