Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qmake escapes spaces within environment variables
Forum Updated to NodeBB v4.3 + New Features

qmake escapes spaces within environment variables

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 392 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    I have a linux environment variable defined as:

    export GMT_LIBS='-L/bogusDir -lgmt'
    

    I want to access MYLIBS from within my .pro file and add it to the LIBS variable:

    gmtLibs = $$getenv("GMT_LIBS")
    LIBS += $gmtLibs
    

    But when qmake is generating a Makefile, it escapes the space within GMT_LIBS with back-slash, so the Makefile contains:

    LIBS          = $(SUBLIBS) -L/bogusDir\ -lgmt
    

    When ‘make’ processes this Makefile, it does not link with library -lgmt, so results in “undefined reference” errors. If I manually edit the Makefile and remove the ‘\’ preceding -lgmt, then rerun ‘make’, it links properly.

    I get the same escaped space in the Makefile if the .pro file accesses environment variable with this instead of getenv():

    LIBS += $$(GMT_LIBS)
    

    So how do I convince qmake not to escape spaces within environment variables?

    Thanks!

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Since these are two parameters but you treat it as one I would go with split()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Tom assoT 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Since these are two parameters but you treat it as one I would go with split()

        Tom assoT Offline
        Tom assoT Offline
        Tom asso
        wrote on last edited by
        #3

        @Christian-Ehrlicher - that works!

        LIBS += $$split(gmtLibs, " ")
        

        Thanks!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved