Search code examples
c++linuxeclipseenvironment-variableseclipse-cdt

How to use System enviroment Variables in Eclipse CDT


I appended to my .bashrc file the following lines:

SYSTEMC="/usr/local/systemc-2.3.1/"
SYSTEMC_INCLUDE="/usr/local/systemc-2.3.1/includes"
SYSTEMC_LIBS="/usr/local/systemc-2.3.1/lib-linux"

and I can do this in my terminal:

$ echo $SYSTEMC
/usr/local/systemc-2.3.1/

So everything here looks fine.

Now I added in Eclipse Project properties->c/C++ build->settings->GCC C++ Compiler->Include this: $(SYSTEMC_INCLUDE)

The resulting makefile contains this line:

g++ -I$(SYSTEMC_INCLUDE) -O0...

But if I run this and look in the console the SYSTEMC_INCLUDE var seems to be empty:

g++ -I -O0 ....

What can I do to propagate my system enviroment variables to Eclipse? Is it because .bashrc is only for the shell? Should I export them somewhere else? Should I add the export statements in the .bashrc file?


Solution

  • You're correct, .bashrc is only used when a user opens a bash shell. Since you're on linux, to export environment variables system wide (and by extension to GUI applications), use /etc/environment.