【问题标题】:How to solve link errors while MediaFoundation using?Media Foundation 使用时如何解决链接错误?
【发布时间】:2020-12-21 12:30:13
【问题描述】:

我有一个可行的解决方案,然后我需要添加一个实现MediaFoundation 的项目。因此,为了包含它,我将此项目添加为现有项目,然后在常规部分的配置中我提供了.h 文件的路径,然后在 Liker 输入中添加了.lib

在此之后,我尝试使用它并在我的一个文件中写入include,然后从添加的这个项目中调用一些方法。

当我尝试编译我的项目时出现错误:

9>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFStartup referenced in function "private: bool __cdecl co_AudioDecoderMF::InitAndStartCOMLib(void)" (?InitAndStartCOMLib@co_AudioDecoderMF@@AEAA_NXZ)
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFShutdown referenced in function "public: virtual void __cdecl co_AudioDecoderMF::Cleanup(void)" (?Cleanup@co_AudioDecoderMF@@UEAAXXZ)
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFCreateAttributes referenced in function "private: bool __cdecl co_AudioDecoderMF::CreateSourceReader(void)" (?CreateSourceReader@co_AudioDecoderMF@@AEAA_NXZ)
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFCreateMediaType referenced in function "private: bool __cdecl co_AudioDecoderMF::ConfigureAudioStream(enum co_AudioDecoder::SoundDataType,struct IMFSourceReader *,struct IMFMediaType * *)" (?ConfigureAudioStream@co_AudioDecoderMF@@AEAA_NW4SoundDataType@co_AudioDecoder@@PEAUIMFSourceReader@@PEAPEAUIMFMediaType@@@Z)
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFCreateMFByteStreamOnStream referenced in function "private: bool __cdecl co_AudioDecoderMF::CreateByteStream(unsigned char const *,__int64)" (?CreateByteStream@co_AudioDecoderMF@@AEAA_NPEBE_J@Z)
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFCreateSourceReaderFromByteStream referenced in function "private: bool __cdecl co_AudioDecoderMF::CreateSourceReader(void)" (?CreateSourceReader@co_AudioDecoderMF@@AEAA_NXZ)
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MFAudioFormat_PCM
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MF_MT_MAJOR_TYPE
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MF_MT_SUBTYPE
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MF_MT_AUDIO_NUM_CHANNELS
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MF_MT_AUDIO_SAMPLES_PER_SECOND
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MF_MT_AUDIO_BLOCK_ALIGNMENT
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MF_MT_AUDIO_BITS_PER_SAMPLE
9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2001: unresolved external symbol MFMediaType_Audio

首先这很奇怪,因为我已经在其他解决方案中使用了这个项目并且没有问题,但是经过研究我发现我需要添加配置Linker -> input更多@987654327 @s

Mf.lib
Mfplat.lib
mfuuid.lib

(启发我在我的其他解决方案中没有这些行),在我添加这些行之后,很多错误消失了,但还剩下一个

9>co_AudioDecoder.lib(co_AudioDecoderMF.obj) : error LNK2019: unresolved external symbol MFCreateSourceReaderFromByteStream referenced in function "private: bool __cdecl co_AudioDecoderMF::CreateSourceReader(void)" (?CreateSourceReader@co_AudioDecoderMF@@AEAA_NXZ)

而且我还没有找到关于如何解决它的任何信息。我是一个相对较新的 C++ 新手,看起来很奇怪,为了使 MediaFoundation(big lib) 正常工作,我需要花费几个小时来找出要添加的额外内容才能使其正常工作。

所以,问题是 - 我在这里错过了什么?

【问题讨论】:

    标签: c++ c ms-media-foundation


    【解决方案1】:

    你需要包括这个:

    #pragma comment(lib, "mfreadwrite")

    文档通常会有所帮助:

    MFCreateSourceReaderFromByteStream function

    【讨论】:

      猜你喜欢
      • 2010-11-01
      • 1970-01-01
      • 2010-12-31
      • 2011-05-25
      • 2011-10-17
      • 1970-01-01
      • 2015-07-21
      • 2014-01-10
      • 1970-01-01
      相关资源
      最近更新 更多