c++ - Directshow C++ CLR 中未解析的 token (0A00001x)

标签 c++ clr directshow linker-errors

我正在尝试将 PlayCap 从 microsoft SDK 从 C++ 迁移到 C++ CLR。​​

目前,我不断在 directshow 类(class)中学习 LNK2020 和 LNK2001。

    public ref class Form1 : public System::Windows::Forms::Form
{
public:
    static IVideoWindow * DC_VW = NULL;
    static IMediaControl *DC_MC = NULL;
    static IMediaEventEx *DC_ME = NULL;
    static IGraphBuilder *DC_GB = NULL;
    static ICaptureGraphBuilder2 * DC_CGB2 = NULL;
    Form1(void)
    {

        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::Button^  button1;
protected: 
private: System::Windows::Forms::Panel^  panel1;

private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        this->button1 = (gcnew System::Windows::Forms::Button());
        this->panel1 = (gcnew System::Windows::Forms::Panel());
        this->SuspendLayout();
        // 
        // button1
        // 
        this->button1->Location = System::Drawing::Point(136, 324);
        this->button1->Name = L"button1";
        this->button1->Size = System::Drawing::Size(217, 53);
        this->button1->TabIndex = 0;
        this->button1->Text = L"button1";
        this->button1->UseVisualStyleBackColor = true;
        this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
        // 
        // panel1
        // 
        this->panel1->Location = System::Drawing::Point(37, 31);
        this->panel1->Name = L"panel1";
        this->panel1->Size = System::Drawing::Size(444, 269);
        this->panel1->TabIndex = 1;
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(511, 389);
        this->Controls->Add(this->panel1);
        this->Controls->Add(this->button1);
        this->Name = L"Form1";
        this->Text = L"Form1";
        this->ResumeLayout(false);

    }
#pragma endregion
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
         {
            HRESULT hr;
            IBaseFilter *DC_SF = NULL;

            hr = GetInterfaces();
            if(FAILED(hr))
            {
                int x = ::MessageBox(NULL, (LPCWSTR)L"Failed to get interfaces. hr=0x%x", (LPCWSTR)L"OK", MB_OK);
            }
            hr = DC_CGB2->SetFiltergraph(DC_GB);
            if(FAILED(hr))
            {
                int x = ::MessageBox(0, (LPCWSTR)L"failed to set filter graph hr=0x%x", (LPCWSTR)L"OK", MB_OK);
            }
            //hr = FindCaptureDevice(&DC_SF);
         }
private: HRESULT GetInterfaces(void)
         {
             HRESULT hr;

             void* Temp;
             hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **) &Temp);
             DC_GB = (IGraphBuilder*)Temp;
             if(FAILED(hr))
             {
                 return hr;
             }

             hr = CoCreateInstance (CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void **)&Temp);
             DC_CGB2 = (ICaptureGraphBuilder2*)Temp;
             if(FAILED(hr))
                 return hr;

             hr = DC_GB->QueryInterface(IID_IMediaControl, (LPVOID*) &Temp);
             DC_MC = (IMediaControl*)Temp;
             if(FAILED(hr))
                 return hr;

             hr = DC_GB->QueryInterface(IID_IVideoWindow, (LPVOID*) &Temp);
             DC_VW = (IVideoWindow*)Temp;
             if(FAILED(hr))
                 return hr;

             hr = DC_GB->QueryInterface(IID_IMediaEventEx, (LPVOID*) &Temp);
             DC_ME = (IMediaEventEx*)Temp;
             if(FAILED(hr))
                 return hr;

             hr = DC_ME->SetNotifyWindow(panel1->Handle.ToInt64(), WM_APP+1, 0);
             return hr;
         }
};

到目前为止,这几乎是 PlayCap 代码的要点,只是我必须移动声明并使其静态。

我不断得到

1>DirectshowC++.obj : error LNK2020: unresolved token (0A000012) IID_IMediaEventEx
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000013) IID_IVideoWindow
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000014) IID_IMediaControl
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000016) CLSID_CaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000017) IID_ICaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000018) CLSID_FilterGraph
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000019) IID_IGraphBuilder
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IMediaEventEx
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IVideoWindow
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IMediaControl
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_ICaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2001: unresolved external symbol CLSID_CaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IGraphBuilder
1>DirectshowC++.obj : error LNK2001: unresolved external symbol CLSID_FilterGraph

它们都在 strmif.h 头文件中,它找到了该文件和它们,但不知道链接器错误是怎么回事

最佳答案

您可能想要链接到 strmiids.lib 和 strmbase.lib。

关于c++ - Directshow C++ CLR 中未解析的 token (0A00001x),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10506790/

相关文章:

c# - 找不到入口点

python - 通过 pybind11 使用 google/draco 作为 lib 构建

.net - Silverlight 和普通 .NET Framework 之间的 CLR 差异?

clr - 用 JavaScript 或 C++ 编写的 Metro 风格应用程序是否加载 CLR?

ffmpeg - 如何将 directshow 的 graphedit 输出发送到 FFMPEG?

c++ - DirectShow 示例过滤器 : How to Use?

delphi - 尽管输出文件为 "smooth",但在渲染 DirectShow 过滤器期间出现卡顿

c++ - 数据结构 : Many (A) to many (B) relationship, 每个链接也有自己的数据 (C)

c++ - 可靠的 WinSock API 确定我的机器上使用的字节序

.NET CLR - 将 CIL 编译为特定于平台的指令时,新的 CPU 体系结构等呢?