Environment variable blank inside application
Posted
by
Jake
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Jake
Published on 2012-04-08T22:40:14Z
Indexed on
2012/04/08
23:47 UTC
Read the original article
Hit count: 246
environment-variables
I have an environment variable that I've set in ~/.profile
with the following line:
export APPDIR=/path/to/dir
When I log in and load up a terminal, I can verify that the variable is set:
$ printenv APPDIR
/path/to/dir
I'm trying to access this variable from within a Qt application:
QString appdir = getenv("APPDIR");
QTWARNING("dir: |" + appdir + "|");
The warning window that pops up shows me:
dir: ||
What is going on here? Am I misunderstanding about how environment variables work in Ubuntu?
This is with a C++/Qt App on Ubuntu 11.10 x86.
© Ask Ubuntu or respective owner