Environment variables and different runtimes linked into executable

  • Thread starter Thread starter Tom Kacvinsky
  • Start date Start date
T

Tom Kacvinsky

Guest
I read

Application ignores env variables setting

It is not clear to me what I should be doing to get the environment variable set properly in my application.

The setup is that I need to link against Python 2.7's import library, which was built with Visual Studio 2008 and also link against the Visual Studio 2017 import libraries. I am using the setenv function call. I also tried the SetEnvironmentVariable function call. Neither worked.

Below is the output of

dumpbin /depdendents manage.exe

$ dumpbin /dependents manage.exe
Microsoft (R) COFF/PE Dumper Version 14.16.27031.1
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file manage.exe

File Type: EXECUTABLE IMAGE

Image has the following dependencies:

Qt3Support4.dll
QtGui4.dll
QtXml4.dll
QtNetwork4.dll
QtCore4.dll
vxml_c.dll
cutilsforada.dll
libcommoncpp_cutilsforada.dll
boost_date_time-vc141-mt-x64-1_69.dll
boost_filesystem-vc141-mt-x64-1_69.dll
boost_python27-vc141-mt-x64-1_69.dll
python27.dll
VcAppLib.dll
sqlite3.dll
cinterfacetoada.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
ADVAPI32.dll
COMCTL32.dll
COMDLG32.dll
dhcpcsvc.DLL
KERNEL32.dll
NETAPI32.dll
ole32.dll
OLEAUT32.dll
SHELL32.dll
SHLWAPI.dll
USER32.dll
USERENV.dll
WS2_32.dll
MSVCP140.dll
VCRUNTIME140.dll
libcommonqt_cutilsforada.dll
CRYPT32.dll
WINTRUST.dll


So there is the Visual Studio 2017 run time DLLs linked. But you will also see python27.dll in the dependents, and running dumpbin on that results in

$ dumpbin /dependent python27.dll
Microsoft (R) COFF/PE Dumper Version 14.16.27031.1
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file python27.dll

File Type: DLL

Image has the following dependencies:

KERNEL32.dll
USER32.dll
ADVAPI32.dll
SHELL32.dll
MSVCR90.dll

Summary

8C000 .data
1D000 .pdata
10F000 .rdata
8000 .reloc
1000 .rsrc
1A6000 .text


and here one can see that the Visual Studio 2008 run time DLL appears.


So, the question is this: if I set an envionment variable in a Visual Studio 2017 produced executable, will it be seen by the DLL built with Visual Studio 2008? My understanding is that things like environment variables are not shared between DLLs, so I am out of luck. The variable my be set correctly in the VS 2017 application, but not picked up by Python 2.7's VS 2008 run time dependency.

Is there anything I need to provide to give more details as how to fix this (if possible)?


Thanks,


TOm

Continue reading...
 
Back
Top