- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my Project, I refer to an environment variable in the "Additional Include Directories" which needs to be set before the build can proceed:
..\\..\\include
%inst_drive%:\\Program Files\\Prog\\commons
"inst_drive" may be different on different machines
I tried setting the environment variable as a pre-build instruction, but it still can't find the includes it needs.
I suspect the include directories are searched and set up befoe the pre-build instruction is executed.
Any idea how to do this?
..\\..\\include
%inst_drive%:\\Program Files\\Prog\\commons
"inst_drive" may be different on different machines
I tried setting the environment variable as a pre-build instruction, but it still can't find the includes it needs.
I suspect the include directories are searched and set up befoe the pre-build instruction is executed.
Any idea how to do this?
Link Copied
11 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The syntax to use here is:
$(inst_drive)
The % syntax is primarily used by the command parser, though why Microsoft didn't also use it here I don't know.
$(inst_drive)
The % syntax is primarily used by the command parser, though why Microsoft didn't also use it here I don't know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tried that, still same problem:
Compiling with Intel Visual Fortran 11.1.060 [IA-32]...
efracr.for
Project : warning PRJ0018 : The following environment variables were not found:
$(inst_drive)
However, it is interesting in that it still compiled even though it couldn't work out what the installation drive $(inst_drive) is. Expanding the command line gives:
Compiling with Intel Visual Fortran 11.1.060 [IA-32]...
ifort /nologo /debug:full /Od /fpp /I"..\..\include" /I":\Program Files\Prog\commons" /DWIN32 /DAWINNTN /gen-interfaces /warn:interfaces /assume:dummy_aliases /names:uppercase /iface:cvf /traceback /libs:dll /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" "efracr.for"
Note that it is able to find the include by properly interpreting the bold bit above even though the drive is not specified! (ie. $(inst_drive) not found)
Compiling with Intel Visual Fortran 11.1.060 [IA-32]...
efracr.for
Project : warning PRJ0018 : The following environment variables were not found:
$(inst_drive)
However, it is interesting in that it still compiled even though it couldn't work out what the installation drive $(inst_drive) is. Expanding the command line gives:
Compiling with Intel Visual Fortran 11.1.060 [IA-32]...
ifort /nologo /debug:full /Od /fpp /I"..\..\include" /I":\Program Files\Prog\commons" /DWIN32 /DAWINNTN /gen-interfaces /warn:interfaces /assume:dummy_aliases /names:uppercase /iface:cvf /traceback /libs:dll /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" "efracr.for"
Note that it is able to find the include by properly interpreting the bold bit above even though the drive is not specified! (ie. $(inst_drive) not found)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use that syntax frequently and it works for me. In what context is INST_DRIVE defined? What I do to diagnose such things is add a post-build step with the command "SET" to show me all the environment variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's the problem- inst_drive is not set when the project is loaded. I need the VFPROJ to run a batch file to set it, so I added the batch file file as a Pre-build process, which did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this. Create a batch file that sets the environment variable and then invokes devenv.exe
You can also play with the project property Debugging > Environment. You can use this to set environment variables (I believe the syntax is VARNAME=value)
You can also play with the project property Debugging > Environment. You can use this to set environment variables (I believe the syntax is VARNAME=value)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the former above already implemented for my batch build process, that is not a problem. What I want is for a new developer to just fire up VS2008, load the project and go, ie. get the project to set up the environment variable and then build.
I looked at Debugging environment, but it looks like that is only for debugging, ie. the project must already have been built. My problem is at build time.
I looked at Debugging environment, but it looks like that is only for debugging, ie. the project must already have been built. My problem is at build time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since it seems that you do not wish to set a system INST_DRIVE environment variable, is it safe to assume that you want multiple projects to have different INST_DRIVE variables?
One of the common techniques to do this is to
1) create the batch file as suggested by Steve (sets environment variable and calls devenv.exe)
2) create a shortcut to this batch file
3) optionally assign the Visual Studion Icon to this shortcut
4) name the text on the shortcut to something related to your project
5) place this shortcut into project launch folder (or on desktop)
Now user does not launch VS then pick project
Rather user picks project and launches VS
An alternate means is to define as system envrionment variables
INST_A=...
INST_B=...
...
(or INST_Project_foo=...)
Then have in your project the choice of which INST_x variable to use.
This provides you a means external to VS to rearrange your placements by editing the system environment variables.
Jim Dempsey
One of the common techniques to do this is to
1) create the batch file as suggested by Steve (sets environment variable and calls devenv.exe)
2) create a shortcut to this batch file
3) optionally assign the Visual Studion Icon to this shortcut
4) name the text on the shortcut to something related to your project
5) place this shortcut into project launch folder (or on desktop)
Now user does not launch VS then pick project
Rather user picks project and launches VS
An alternate means is to define as system envrionment variables
INST_A=...
INST_B=...
...
(or INST_Project_foo=...)
Then have in your project the choice of which INST_x variable to use.
This provides you a means external to VS to rearrange your placements by editing the system environment variables.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Jim. I will probably choose the latter method. (Although I was hoping that VS could run a batch file for me before it referenced the environment variable, but I guess this isn't possible- at least not in the Additional Libraries).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a reason why you cannot set the environment variable on each machine using Control Panel ?
Even if it is different for each machine, once it has been set for a machineit can be left until it changes. That way you don't need to bother about batch files etc just click on theVS icon, or the project's solution icon, the environment variable will be there waiting.
Les
Even if it is different for each machine, once it has been set for a machineit can be left until it changes. That way you don't need to bother about batch files etc just click on theVS icon, or the project's solution icon, the environment variable will be there waiting.
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I can, just that I don't want to become the "install geek". Where I can get something done automatically by software, I always follow that route.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Steve's correct that "the syntax to use here is $(inst_drive)" but I'm less sure that "the % syntax is primarily used by the command parser". The documentation on working with project properties suggests that the syntax %(name) is used for item macros.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page