Re: RegisterStaticModules depreciated -> how to register formats now?

Bob Friesenhahn <[email protected]> Tue, 11 Feb 2020 08:34:33 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Tue, 11 Feb 2020, Pro Turm wrote:

> With that I mean, that I cannot call OpenModule() from within a C++ 
> class (calling a static extern c function is not C++ language 
> supported).

It was never intended that API users should ever call OpenModule() 
since this is an internal implementation function.

> You suggestion of using GetMagickInfo would also not work, since it contains #if defined(SupportMagickModules), which is  only defined for
> #if defined(HasLTDL)
> #  define SupportMagickModules
> #elif !defined(__MINGW32__) && !defined(__MINGW64__)
> #  if defined(MSWINDOWS) && defined(_DLL)
> #    define SupportMagickModules
> #  endif
> #endif
>
> i.e. is NOT for static linking ...

Does your GraphicsMagick compile?  If so, GetMagickInfo() must work 
because it is invoked from 16 places in the code.  GetMagickInfo() is 
a public function.

> So, the question would be stated like this: could you please provide 
> an example of calling the OpenModule() or similar, which 
> registerPNGformat-s with static linking?

It should be suffient to do

const MagickInfo *magick_info;
ExceptionInfo exception;

GetExceptionInfo(&exception);

magick_info=GetMagickInfo("MYFORMAT", exception);

and now the module registration function corresponding to "MYFORMAT" 
should have been invoked one time.

Normally this is not something you would need to do (other than to 
learn more about ""MYFORMAT") since this function is already called 
many times by existing code.

If GraphicsMagick is later destroyed, then the module destruction 
function will be invoked.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt