Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Project-specific environment variables appear to only get defined in Debug(Eclipse CDT application execution environment)
Project-specific environment variables appear to only get defined in Debug [message #1398041] Thu, 10 July 2014 14:16 Go to next message
CGO SenseiC is currently offline CGO SenseiCFriend
Messages: 16
Registered: July 2011
Junior Member
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"):

  1. Selected the Debug Configuration from the pull-down menu
  2. Clicked Add... and set the Name to OMQLIB and Value to DEBUG
  3. Selected the Release Configuration
  4. 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:
index.php/fa/18514/0/

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 14:24]

Report message to a moderator

Re: Project-specific environment variables appear to only get defined in Debug [message #1398052 is a reply to message #1398041] Thu, 10 July 2014 14:34 Go to previous messageGo to next message
CGO SenseiC is currently offline CGO SenseiCFriend
Messages: 16
Registered: July 2011
Junior Member
For the record, I see the identical behavior with:
Version: Kepler Service Release 2
Build id: 20140224-0627

SenseiC bows out.
Re: Project-specific environment variables appear to only get defined in Debug [message #1398616 is a reply to message #1398052] Fri, 11 July 2014 10:15 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Quote:
I right-clicked on the project, chose Properties, expanded C/C++ Build, selected Environment,

Wrong place. Here you define the environment for your *build*.

What you want, is to define the environment for the debug/run launch.
http://help.eclipse.org/luna/topic/org.eclipse.cdt.doc.user/getting_started/cdt_w_debug.htm?cp=9_1_7


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Project-specific environment variables appear to only get defined in Debug [message #1399401 is a reply to message #1398616] Sat, 12 July 2014 14:52 Go to previous message
CGO SenseiC is currently offline CGO SenseiCFriend
Messages: 16
Registered: July 2011
Junior Member
Sigh. Kind of like an episode of "Brain Games"... I saw the word Build, but never bothered to apply it to the phrase build environment. "I see!", said the blind man to his deaf horse.

Of course now I look at it and it makes perfect sense.

Too bad I can't say the same about the decision to have the compiler Include Paths specified in the top pane and the Include Files in the lower pane... and the exact opposite for Linker libraries. Rolling Eyes

Thank you for your assistance.

SenseiC bows out.

[Updated on: Sat, 12 July 2014 14:53]

Report message to a moderator

Previous Topic:odd problem with CDT parser
Next Topic:"File sensitive" build configuration
Goto Forum:
  


Current Time: Tue Apr 23 11:35:53 GMT 2024

Powered by FUDForum. Page generated in 0.03484 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top