Project-specific environment variables appear to only get defined in Debug [message #1398041] |
Thu, 10 July 2014 10:16  |
Eclipse User |
|
|
|
I don't know if I misconfigured something, but near as I can tell, project-specific environment variables only get defined when executed in Debug.
My Environment:
- Version: Luna Release (4.4.0)
- Build id: 20140612-0600
- Windows 7 x64 with MinGW installed using mingw-get-setup.exe
- java -version --> java version "1.7.0_51"
- gcc version 4.8.1 (GCC)
I created a new "Hello World C++ project" using the MinGW GCC Toolchain and replaced the template code with the following (made it about as small as I could for this post):#include <iostream>
#include <cstdlib>
int main() {
std::string varname("OMQLIB");
char *envvalue = std::getenv( varname.c_str() );
if( envvalue != NULL )
std::cout << varname << " defined as: " << envvalue << std::endl;
else
std::cout << varname << " not defined" << std::endl;
return 0;
} I right-clicked on the project, chose Properties, expanded C/C++ Build, selected Environment, and then did the following (leaving the radio button as "Append variables to native environment"):
- Selected the Debug Configuration from the pull-down menu
- Clicked Add... and set the Name to OMQLIB and Value to DEBUG
- Selected the Release Configuration
- Clicked Add... and set the Name to OMQLIB and Value to RELEASE
I did all this after trying simply setting the same variable for all configurations, etc.
When I run the Debug configuration of my application, as expected it generates following output:
OMQLIB defined as: DEBUG
So far so good, but unfortunately when I run the Release configuration of my application generates following output:
OMQLIB not defined
I tried setting the variable in "All Configurations" with the same behavior.
My final test I "manually" defined the variable for my "Release configuration" in the Run Configurations screen itself:

And finally I got this output:
OMQLIB defined as: Manually Set
Any ideas on why the project-definition of an environment variable doesn't seem to work except for Debug, but (thankfully) manually setting it for the specific run configuration does?
SenseiC bows out.
[Updated on: Thu, 10 July 2014 10:24] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.23911 seconds