"LNK2019: unresolved external symbol" 错误解决建议
"LNK2019: unresolved external symbol" error resolution suggestions
检查了已经提出的问题,但找不到解决方案。
中提供的示例
<Page
x:Class="ButtonApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ButtonApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<!--Sets up a RepositionThemeAnimation using the FromHorizontalOffset property
to start the animation from the old location.-->
<Storyboard x:Name="PointerReleasedStoryboard">
<RepositionThemeAnimation Storyboard.TargetName="myRectangle" FromHorizontalOffset="-400"/>
</Storyboard>
</Grid.Resources>
<Rectangle x:Name="myRectangle"
HorizontalAlignment="Left"
Width="200"
Height="200"
Fill="Blue"
PointerReleased="myRectangle_PointerReleased"
/>
</Grid>
</Page>
在MainPage.h中我添加了
#pragma once
#include "MainPage.g.h"
namespace winrt::ButtonApp::implementation
{
struct MainPage : MainPageT<MainPage>
{
MainPage();
int32_t MyProperty();
void MyProperty(int32_t value);
void myRectangle_PointerReleased(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
};
}
namespace winrt::ButtonApp::factory_implementation
{
struct MainPage : MainPageT<MainPage, implementation::MainPage>
{
};
}
在MainPage.cpp
#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
using namespace winrt;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Media::Animation;
namespace winrt::ButtonApp::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
}
void winrt::ButtonApp::implementation::MainPage::myRectangle_PointerReleased(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
myRectangle().Margin({ 400, 0, 0, 0 });
PointerReleasedStoryboard().Begin();
}
pch.h 文件:
#pragma once
#include <windows.h>
#include <unknwn.h>
#include <restrictederrorinfo.h>
#include <hstring.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.UI.Xaml.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.UI.Xaml.Data.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.UI.Xaml.Markup.h>
#include <winrt/Windows.UI.Xaml.Navigation.h>
#include <winrt/Windows.UI.Xaml.Media.Animation.h>
#include <winrt/Windows.UI.Xaml.Shapes.h>
不确定缺少什么我收到此错误
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall winrt::Windows::UI::Xaml::Input::PointerEventHandler::PointerEventHandler<class <lambda_304a3567805bccbaf9da8ada06fcdf84> >(class <lambda_304a3567805bccbaf9da8ada06fcdf84>)" (??$?0V<lambda_304a3567805bccbaf9da8ada06fcdf84>@@@PointerEventHandler@Input@Xaml@UI@Windows@winrt@@QAE@V<lambda_304a3567805bccbaf9da8ada06fcdf84>@@@Z) referenced in function "public: void __thiscall winrt::ButtonApp::implementation::MainPageT<struct winrt::ButtonApp::implementation::MainPage>::Connect(int,struct winrt::Windows::Foundation::IInspectable const &)" (?Connect@?$MainPageT@UMainPage@implementation@ButtonApp@winrt@@$$V@implementation@ButtonApp@winrt@@QAEXHABUIInspectable@Foundation@Windows@4@@Z) ButtonApp D:\ButtonApp\XamlTypeInfo.g.obj 1
感谢大家的帮助。
我在 pch.h 中添加了一个缺失的“#include ”并且成功了。
检查了已经提出的问题,但找不到解决方案。
中提供的示例<Page
x:Class="ButtonApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ButtonApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<!--Sets up a RepositionThemeAnimation using the FromHorizontalOffset property
to start the animation from the old location.-->
<Storyboard x:Name="PointerReleasedStoryboard">
<RepositionThemeAnimation Storyboard.TargetName="myRectangle" FromHorizontalOffset="-400"/>
</Storyboard>
</Grid.Resources>
<Rectangle x:Name="myRectangle"
HorizontalAlignment="Left"
Width="200"
Height="200"
Fill="Blue"
PointerReleased="myRectangle_PointerReleased"
/>
</Grid>
</Page>
在MainPage.h中我添加了
#pragma once
#include "MainPage.g.h"
namespace winrt::ButtonApp::implementation
{
struct MainPage : MainPageT<MainPage>
{
MainPage();
int32_t MyProperty();
void MyProperty(int32_t value);
void myRectangle_PointerReleased(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
};
}
namespace winrt::ButtonApp::factory_implementation
{
struct MainPage : MainPageT<MainPage, implementation::MainPage>
{
};
}
在MainPage.cpp
#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
using namespace winrt;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Media::Animation;
namespace winrt::ButtonApp::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
}
void winrt::ButtonApp::implementation::MainPage::myRectangle_PointerReleased(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
myRectangle().Margin({ 400, 0, 0, 0 });
PointerReleasedStoryboard().Begin();
}
pch.h 文件:
#pragma once
#include <windows.h>
#include <unknwn.h>
#include <restrictederrorinfo.h>
#include <hstring.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.UI.Xaml.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.UI.Xaml.Data.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.UI.Xaml.Markup.h>
#include <winrt/Windows.UI.Xaml.Navigation.h>
#include <winrt/Windows.UI.Xaml.Media.Animation.h>
#include <winrt/Windows.UI.Xaml.Shapes.h>
不确定缺少什么我收到此错误
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall winrt::Windows::UI::Xaml::Input::PointerEventHandler::PointerEventHandler<class <lambda_304a3567805bccbaf9da8ada06fcdf84> >(class <lambda_304a3567805bccbaf9da8ada06fcdf84>)" (??$?0V<lambda_304a3567805bccbaf9da8ada06fcdf84>@@@PointerEventHandler@Input@Xaml@UI@Windows@winrt@@QAE@V<lambda_304a3567805bccbaf9da8ada06fcdf84>@@@Z) referenced in function "public: void __thiscall winrt::ButtonApp::implementation::MainPageT<struct winrt::ButtonApp::implementation::MainPage>::Connect(int,struct winrt::Windows::Foundation::IInspectable const &)" (?Connect@?$MainPageT@UMainPage@implementation@ButtonApp@winrt@@$$V@implementation@ButtonApp@winrt@@QAEXHABUIInspectable@Foundation@Windows@4@@Z) ButtonApp D:\ButtonApp\XamlTypeInfo.g.obj 1
感谢大家的帮助。
我在 pch.h 中添加了一个缺失的“#include