UPDATE: Eclipse is the problem — it’s working from console. But I’d still like it to work in Eclipse.
My printenv output contains the line:
PROTCAD3DIR=/home/brent/Desktop/protCAD
But from the program I’m trying to run (in Eclipse), I get output:
Environment variable PROTCAD3DIR undefined.
Please set it properly and re-execute the program.
I searched for this message in the source and found 1 result:
string PCGeneralIO::getEnvironmentVariable(const string& _evname)
{
const char* convEVName = _evname.c_str();
char* pEVString = getenv(convEVName);
if (pEVString == 0)
{ cout << "Environment variable " << _evname << " undefined." << endl;
cout << "Please set it properly and re-execute the program." << endl;
exit(1);
}
string EVstring = charToString(pEVString);
return EVstring;
}
I’m pretty sure this is calling the above function:
string evname = "PROTCAD3DIR";
string path = PCGeneralIO::getEnvironmentVariable(evname);
So what could be causing getenv() to find it as undefined?
Check the “Environment” Tab in the Eclipse “Run Configuration” for your program. The list should be empty and “Append environment to native environment” should be checked.
Edit if that does not help, then most probably Eclipse has not been started with the missing variable. Check this by creating a new “External Tool Configuration” using
/usr/bin/printenvas the program. Start this external tool and examine the output. If the missing variable is not mentioned, then you have to specify exactly thepart from your comment 🙂