Search code examples
c++visual-studiodllmakefiledirectshow

RGBFilters entry-point DllRegisterServer was not found


I'm trying to build a DirectShow application with multiple cameras that may be connected, disconnected, or attached to preview monitors at arbitrary times, leaving the application's central processing graph running. The architecture looks like this:

target application architecture

Assisted by this post (among other resources), I've gotten GMFBridge working to where the source graphs and processing graph are constructed and connected when the program starts, and the three graphs are theoretically running. However, since none of the rendering windows are attached, I really don't know.

One of the things I discovered along the way is that Color Space Converter filters are needed between the Smart Tee and renderers for the video to work. Consequently, I've got Color Space Converter filters between the Smart Tee and the bridge filters on the assumption they will be enforcing the desired video format.

Now I'm trying to build a Monitor Window graph which starts with a bridge source filter, feeding into a renderer. The first attempt refused to connect the pins because they couldn't agree on a media type. (The error message was "there is no common media type between these pins" in the exception.) I put a Color Space Converter between them, and that got the graph to build, but resulted in a black renderer window. I connected to the running graph using GraphEdit and found the media type on the input to the Color Space Converter is ARGB32, while its output is RGB565. I suspect that's the cause of the black screen, so I searched for a way to make the output be RGB32 to match the camera format. I discovered there's no way to directly set the output format of the Color Space Converter, you have to connect it to a filter that only accepts the desired format. In this post, I found "The TransNull32 from the RGBFilters example does exaclty this."

Once I realized the TransNull32 filter was nowhere to be found on my system, I set off to find the "magical" RGBFilters. In this post I found a link to a Wikipedia page that has a download link for the most recent version of a Microsoft SDK that includes the RGBFilters source code, Windows Server 2003 R2 Platform SDK.

I burned a disc from that image file and installed the SDK on my system. When I went to the RGBFilters directory, I discovered it had a Makefile but no VC++ or VisualStudio files. I created a new VisualStudio2015 project from the Makefile, and went through the process of debugging its build:

  • copy StdAfx.h into all of the subdirectories; copy the (auto-generated) RGBFilters_h.h to RGBFilters.h and copy that into all of the subdirectories to resolve compiler "not found" errors
  • add #include <strsafe.h> to StdAfx.h and re-copy it to the subdirectories
  • streams.h has to be added to the include list (from C:\Program Files\Microsoft\SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses on my system)
  • Strmbasd.lib has to be added to the library list (from C:\Program Files\Microsoft\SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses\Debug on my system), and it has to be built with the same character set as is being used to build RGBFilters.dll, which required a rebuild of that library as well
  • winmm.lib has to be added to the library list (from C:\Program Files\Microsoft\SDKs\Windows\v7.1\Lib on my system)

I finally got RGBFilters.dll built, and tried regsvr32 RGBFilters.dll - and got

regsvr32 RGBFilters.dll failure error message

I thought I'd found the answer in this Microsoft post, but what I got was

Sat 04/22/2017  8:48:00.27 Microsoft Windows [Version 6.1.7601]
C:\...\RGBFilters\Debug > C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm RGBFilters.dll /tlb:RGBFilters.tlb
Microsoft .NET Framework Assembly Registration Utility version 4.6.1055.0
for Microsoft .NET Framework version 4.6.1055.0
Copyright (C) Microsoft Corporation.  All rights reserved.

RegAsm : error RA0000 : Failed to load 'C:\Program Files (x86)\Microsoft\wServer 2003 R2 Platform SDK\Samples\Multimedia\DirectShow\Filters\RGBFilters\Debug\RGBFilters.dll' because it is not a valid .NET assembly

Sat 04/22/2017  8:56:02.02 Microsoft Windows [Version 6.1.7601]
C:\...\RGBFilters\Debug >

Then, following the advice in this post I tried running depends.exe and couldn't find anything that looked like an exports list for the DLL. I also tried

Sat 04/22/2017 10:21:25.33 Microsoft Windows [Version 6.1.7601]
C:\...\RGBFilters\Debug > dumpbin /exports RGBFilters.dll
Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file RGBFilters.dll

File Type: DLL

  Summary

        1000 .00cfg
        7000 .data
        1000 .gfids
        2000 .idata
       22000 .rdata
        6000 .reloc
        1000 .rsrc
       59000 .text

Sat 04/22/2017 10:21:38.61 Microsoft Windows [Version 6.1.7601]
C:\...\RGBFilters\Debug >

As you can see, there are no exported symbols in this DLL - which is why everything chokes on it. I looked through all of the project settings in VisualStudio and don't see anything amiss, so I'm at a loss to explain how this totally bogus DLL got built.

Did I miss some critical step in converting the Makefile into a VS project, as I strongly suspect?

EDIT

There is an RGBFilters.def file, it's listed as one of the source files in the VS project, and it contains

;===========================================================================
;  Copyright (c) 1992-2002  Microsoft Corporation.  All Rights Reserved.
;===========================================================================

EXPORTS
            DllMain                 PRIVATE
            DllGetClassObject       PRIVATE
            DllCanUnloadNow         PRIVATE
            DllRegisterServer       PRIVATE
            DllUnregisterServer     PRIVATE

Solution

  • As noted by Roman R, the RGBFilters.def file needs to be referenced in the project properties, in the Module Definition File field on the Configuration Properties -> Linker -> Input page.

    Once I made that change to the project and rebuilt it, regsvr32 RGBFilters.dll worked as expected.