Reputation: 131525
This C project I'm working on has a script which is run as part of the build, which requires some folder to be in the $PATH. But - other projects shouldn't have it in their path, nor should Eclipse itself. So, this is not about replacing the path but appending to it for a specific project.
I couldn't find a way to do this in Eclipse's project settings dialog; does this feature exist? If not, can you suggest a workaround other than having my script itself append to $PATH?
Upvotes: 3
Views: 4760
Reputation: 7970
To edit the path the build is run with, in the Project Properties
choose C/C++ Build
| Environment
and add your new Path entry by pressing Add...
and filling in PATH
for Name
and /your/path
for VALUE
. Note that CDT assumes that if the variable (PATH
in this case) is already defined that you want to append to it. (You probably want to check the Add to all configurations
check too.)
Here is a screenshot:
In the Environment
tab for the specific launch configuration you want to edit the PATH
, set the PATH
to be /tmp/abcd:${env_var:PATH}
Here is a screenshot of what I mean:
Running the following C program:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
puts("Updated PATH with /tmp/abcd prepended");
puts(getenv("PATH"));
puts("Saved version of PATH in case we need that");
puts(getenv("ORIGPATH"));
return 0;
}
And you should observe this output:
Updated PATH with /tmp/abcd prepended
/tmp/abcd:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Saved version of PATH in case we need that
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Upvotes: 9