Re: Windows MAGICK_CONFIGURE_PATH options

Bob Friesenhahn <[email protected]> Thu, 5 Mar 2020 15:18:29 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
On Thu, 5 Mar 2020, 10bxjfhf wrote:

> While I can get my app - when installed - running by copying the necessary 
> DLL to the executable directory, I see a problem with the definition of 
> MAGICK_CONFIGURE_PATH
>
> My question: can I force the Magick++ code to reconsider the path provided by 
> the ENV variable for a specific app?

For obvious reasons, the code tries a search just one time.  The 
search algorithm is implemented in GetConfigureBlob() in 
magick/blob.c.

It looks like you could use the Windows SetEnvironmentVariable 
function like

   SetEnvironmentVariable("MAGICK_CONFIGURE_PATH","DIR1:DIR2:DIR3")

prior to invoking InitializeMagick().  This is not a great solution, 
but it is likely to work.  This setting does not influence searching 
for DLLs or loadable modules.

The documentation for SetEnvironmentVariable() may be found at 
"https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable".

> While Windows allows me to set up a separate and distinct set of environment 
> variables for any app, the option is not really available as long as I use 
> the libraries as DLLs, because the configuration path is set during DLL 
> initialization, long before my program gets a chance to set up a separate set 
> of environment variable for any specific app.

This flexibility can be available.  See ProvideDllMain in 
VisualMagick/magick/magick_config.h.in.  This option is passed into 
magick/magick_config.h by the 'configure' program so it could be 
edited (disabled) later for testing.  It is true that this is defined 
by default for convenience.  If the program is statically compiled, 
then the DLL initialization functionality is not existing.

It would be nice if GraphicsMagick supported a configuration file for 
this stuff, but it would not solve the chicken and egg problem and of 
course there is added initialization cost for each file search.

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