Sunday 9 June 2013

visual studio 2012 ( vc11) enviornment setting path, lib and include path

Today, I installed the MySQL(mysql-python) for Python. I got lots of troubles on this, since the python invoke the c library and it compiled by VS2008 (vs 9.0), while my laptop's VS is 2012 (vs 11.0).

The two issues for this one:

1, python\Libs\distutils\msvc9compiler.py  the find_vcvarsall(version) function always received version 9 while it should be 11 in my laptop.
2,MySQL Connector C 6.0.2 (the mysql-python invoked c base library) do not provide the include path and lib path. I spent several hours to read and run the python and vcvarsall.bat( the all system variable file)

I find the VC/vcvarsall.bat is the VC variables all generated by this file, it include several vars file for different cpus.
for example, the part of vcvars32 is:

....
@if not "%WindowsSdkDir%" == "" (
    @set "PATH=%WindowsSdkDir%bin\x86;%PATH%"
    @set "INCLUDE=%WindowsSdkDir%include\shared;%WindowsSdkDir%include\um;%WindowsSdkDir%include\winrt;%INCLUDE%"
    @set "LIB=%WindowsSdkDir%lib\win8\um\x86;%LIB%"
    @set "LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;%ExtensionSDKDir%\Microsoft.VCLibs\11.0\References\CommonConfiguration\neutral;%LIBPATH%"
)
....

you can seen the vc include path you can just set system environment variables INCLUDE and the lib you can just set LIB in your system environment variables LIB. The same as libpath setting.