[Qt-interest] How can I use the system envoriment variable in qt project file(.pro) ?

Sean Harmer sean.harmer at maps-technology.com
Sat Nov 14 11:00:04 CET 2009


Hi Kermit,

On Saturday 14 Nov 2009 04:28:39 Kermit Mei wrote:
> Hello Community!
> 
>   How can I use the Linux system variable such as $PATH $QTDIR in .pro
> file ?
>   For example, I want to use:
>   LIBS += -L$QTDIR/lib -lgui
> 
> I want the compiler use argument "-L/opt/qt/lib -lgui" where
> $QTDIR=/opt/qt
> 
> How to do that?

You can access environment variables from within a .pro file by using this 
sort of construct:

$$(MY_ENV_VAR)

You can assign this to another variable, use it to performs checks. For e.g.

TEST = $$(MAPSROOT)
isEmpty( TEST ){
    error( "Go and define the environment variable MAPSROOT" )
}

HTH

Sean



More information about the Qt-interest-old mailing list