Re: command prompt environment settings

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Carl Daniel [VC++ MVP] (cpdaniel_remove_this_and_nospam_at_mvps.org.nospam)
Date: 06/27/04


Date: Sun, 27 Jun 2004 08:51:24 -0700

RG wrote:
> Hello all,
>
> I have two questions regarding the command prompt environment settings
> for MS Visual Studio .Net (Under Windows XP Pro).
>
> 1. I wrote a small opengl program in C++ and compiled it within the
> Command Prompt as:
>
> cl test.cpp
>
> The program compiled fine and ran fine. My question, even though I did
> not specify the libraries need, ie opengl32.lib and glu32.lib, the
> Linker still managed to figure it out. How did the linker know which
> libraries it needed and how can I change the settings to do the same
> for other libraries?

Look up #pragma comment(lib,...) in the VC++ documentation.

>
> 2. I noticed that the environment settings for the INCLUDE and LIB
> path that are set within the Visual Studio .Net IDE are not available
> for the Visual Studio .Net Command Prompt. Further more, I tried
> adding the relevant paths to these parameters by going to Control
> Panel>System>Advanced>Environment Variables>System Variables. However
> when I checked the setting by using "set | more" within command
> prompt, they were not available. This seems strange since I set other
> parameters and it worked fine. Can someone tell me what is the best
> place to modify the INCLUDE and LIB parameters so that they are
> available both for the Command Prompt and the MSVS.NET IDE.

The IDE has it's own collection of paths that are stored in the registry and
in general, the IDE ignores the environment variables (although there is a
command-line option to devenv.exe to make it use the environment instead).

The command line tools use the environment variables exclusively, and they
most definitely can be set from the control panel. Make sure that after you
change them in the control panel that you close and re-open your command
prompt. The control panel only changes the environment of Explorer.exe -
all other processes (such as cmd.exe) inherit an environment when they're
started and won't see control panel changes to the environment unless
they're restarted.

Since you've compiled from the command line, you probably know about
vcvars32.bat - this batch file is created when Visual Studio is installed
and can be run in a command prompt to set the environment to match the IDE
settings.

-cd



Relevant Pages

  • Re: command prompt environment settings
    ... > I have two questions regarding the command prompt environment settings ... I noticed that the environment settings for the INCLUDE and LIB ... most definitely can be set from the control panel. ...
    (microsoft.public.vc.language)
  • Re: command prompt environment settings
    ... > I have two questions regarding the command prompt environment settings ... I noticed that the environment settings for the INCLUDE and LIB ... most definitely can be set from the control panel. ...
    (microsoft.public.vc.ide_general)
  • Re: command prompt environment settings
    ... > I have two questions regarding the command prompt environment settings ... I noticed that the environment settings for the INCLUDE and LIB ... most definitely can be set from the control panel. ...
    (microsoft.public.vstudio.development)
  • Re: keyboard layout
    ... > OK I organized the files and folder. ... > I tried with build.exe but it answer with errors about no variables set. ... Build.exe needs to be launched from a build environment. ... A command prompt window pops up, with all the environment variables for your platform and project already set. ...
    (microsoft.public.windowsce.platbuilder)
  • command prompt environment settings
    ... I have two questions regarding the command prompt environment settings ... for MS Visual Studio .Net. ... I wrote a small opengl program in C++ and compiled it within the ... I noticed that the environment settings for the INCLUDE and LIB ...
    (microsoft.public.vstudio.general)