Skip to content

DllMain changes environment variables #38

@pcrockett

Description

@pcrockett

NETMapnik only seems to work when the Mapnik data files are in the process's current working directory. I think this is because the GDAL_DATA, PROJ_LIB, and ICU_DATA environment variables are set to relative paths when the DLL is loaded.

BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle,
    IN DWORD     nReason,
    IN LPVOID    Reserved)
{
    switch (nReason)
    {
        case DLL_PROCESS_ATTACH:
            _putenv_s("PROJ_LIB", "share\\proj");
            _putenv_s("ICU_DATA", "share\\icu");
            _putenv_s("GDAL_DATA", "share\\gdal");
            break;
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}

I have tried changing the environment variables back to what they were before the DLL was loaded, but even when I do that, Mapnik still behaves like it wants to use the relative paths.

Is there another way for me to tell Mapnik where the actual GDAL, PROJ, etc. data files reside?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions