What is the difference between the LIB and LIBPATH environment variables for MS Visual C/C++?

大憨熊 提交于 2019-12-18 11:44:40

问题


I've been working on some build scripts, and this is bugging me. I want to be sure that we're independent of environment settings, but in order to be sure of that I feel a need to understand how/where the settings are used by the tools.

The Visual Studio command prompt and/or vcvarsall.bat file set up two distinct environment variables: LIB and LIBPATH. The values are different, but partially overlapping. Here are the values from my system:

LIB=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows Kits\8.0\lib\win8\um\x86;

LIBPATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral;\Microsoft.VCLibs\11.0\References\CommonConfiguration\neutral;

I'd just like to understand the rationale for having two different variables -- a little more than the obvious fact that LIBPATH brings in more libs. I've tried looking it up, but I haven't found a clear definition of when each is used by the linker and/or the dev environment.


回答1:


LIB is for the linker, helps it find import and static libraries.

LIBPATH is for the compiler, helps it find metadata files. Like type libraries, .NET assemblies, WinRT .winmd files.



来源:https://stackoverflow.com/questions/20483619/what-is-the-difference-between-the-lib-and-libpath-environment-variables-for-ms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!