Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Unable to build qtdeclarative (cross-compiling Qt5 for Raspberry Pi zero W): Error ‘PATH_MAX’ was not declared in this scope
Forum Update on Monday, May 27th 2025

Unable to build qtdeclarative (cross-compiling Qt5 for Raspberry Pi zero W): Error ‘PATH_MAX’ was not declared in this scope

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 653 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.
  • G Offline
    G Offline
    glamis
    wrote on 16 Aug 2020, 12:58 last edited by
    #1

    I have successfully cross-compiled qtbase for Raspberry Pi 0 W (by following https://wiki.qt.io/RaspberryPi2EGLFS) , but I'm unable to build the sub-module QtDeclarative for adding QML support. With Qt5.15.0 I'm getting the following error :

    /qtdeclarative/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp:86:14: error: ‘PATH_MAX’ was not declared in this scope
         char buf[PATH_MAX];
    

    What am I doing wrong ?

    1 Reply Last reply
    0
    • J Online
      J Online
      JKSH
      Moderators
      wrote on 16 Aug 2020, 23:24 last edited by
      #2

      @glamis I'm not sure why PATH_MAX isn't found in your source code, but this post should help you understand what it is: https://stackoverflow.com/questions/9449241/where-is-path-max-defined-in-linux

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • L Offline
        L Offline
        Lord_Naikon
        wrote on 3 Oct 2020, 12:13 last edited by Lord_Naikon 10 Mar 2020, 12:14
        #3

        I ran into the same problem using GCC 8.3 as a cross compiler with the latest (as of 3-10-2020) raspbian. I guess that previously PATH_MAX was leaked by another header, hiding this bug. I fixed it by simply replacing the macro PATH_MAX with a constant (1024). That should be plenty of space to hold the 20 or so bytes that are copied into buf, which isn't a real path anyway.

        diff --git a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
        index d59fdcd675..56cd753bb5 100644
        --- a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
        +++ b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
        @@ -74,7 +74,7 @@ static int memfdForUsage(size_t bytes, OSAllocator::Usage usage)
                 break;
             }
         
        -    char buf[PATH_MAX];
        +    char buf[1024 /* PATH_MAX */];
             strcpy(buf, type);
             strcat(buf, "QtQml");
        

        The actual fix is to either include linux/limits.h or fix memfdForUsage() to not allocate such a huge stack buffer for no reason at all.

        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