Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cross compiling QT for raspberry pi - AT_FDCWD was not declared in this scope



  • Hello. I wanted to cross-compile qt for my raspberrypi. I've made working cross-compiler using this article : https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/

    Those are the options used to configure gcc :

    arm-linux-gnueabihf-g++ -v
    Using built-in specs.
    COLLECT_GCC=arm-linux-gnueabihf-g++
    COLLECT_LTO_WRAPPER=/opt/cross/libexec/gcc/arm-linux-gnueabihf/10.1.0/lto-wrapper
    Target: arm-linux-gnueabihf
    Configured with: ../gcc-10.1.0/configure --prefix=/opt/cross --target=arm-linux-gnueabihf --enable-languages=c,c++,fortran --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-multilib
    Thread model: posix
    Supported LTO compression algorithms: zlib zstd
    gcc version 10.1.0 (GCC) 
    

    Here's include list:

    \home\blazej> echo | arm-linux-gnueabihf-g++ -E -Wp,-v -
    ignoring nonexistent directory "/opt/cross/lib/gcc/arm-linux-gnueabihf/10.1.0/../../../../arm-linux-gnueabihf/sys-include"
    #include "..." search starts here:
    #include <...> search starts here:
     /opt/cross/lib/gcc/arm-linux-gnueabihf/10.1.0/include
     /opt/cross/lib/gcc/arm-linux-gnueabihf/10.1.0/include-fixed
     /opt/cross/lib/gcc/arm-linux-gnueabihf/10.1.0/../../../../arm-linux-gnueabihf/include
    End of search list.
    # 1 "<stdin>"
    # 1 "<built-in>"
    # 1 "<command-line>"
    # 31 "<command-line>"
    # 1 "/opt/cross/arm-linux-gnueabihf/include/stdc-predef.h" 1 3
    # 32 "<command-line>" 2
    # 1 "<stdin>"
    

    When i try to compile qt using this configure script:

    ./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /mnt/linux_hdd/sysroot -opensource -confirm-license -skip qtserialbus -skip qtscxml -skip qtscript -skip qtcharts -skip qt3d -skip qtdatavis3d -skip qtcanvas3d -skip qtgamepad -skip qtvirtualkeyboard -skip qtwayland -skip qtwebengine -skip qtwebchannel -skip qtwebglplugin -skip qtwebsockets -make libs -prefix /usr/local/qt5pi -extprefix /mnt/linux_hdd/qt_rasp/qt5pi -hostprefix /mnt/linux_hdd/qt_rasp/qt5 -no-use-gold-linker -v -no-gbm
    

    This error occurs:

    io/qfilesystemengine_unix.cpp: In function ‘int qt_statx(const char*, statx*)’:
    io/qfilesystemengine_unix.cpp:321:26: error: ‘AT_FDCWD’ was not declared in this scope
      321 |     return qt_real_statx(AT_FDCWD, pathname, 0, statxBuffer);
          |                          ^~~~~~~~
    io/qfilesystemengine_unix.cpp: In function ‘int qt_lstatx(const char*, statx*)’:
    io/qfilesystemengine_unix.cpp:326:26: error: ‘AT_FDCWD’ was not declared in this scope
      326 |     return qt_real_statx(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, statxBuffer);
          |                          ^~~~~~~~
    io/qfilesystemengine_unix.cpp:326:46: error: ‘AT_SYMLINK_NOFOLLOW’ was not declared in this scope
      326 |     return qt_real_statx(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, statxBuffer);
          |                                              ^~~~~~~~~~~~~~~~~~~
    io/qfilesystemengine_unix.cpp: In function ‘int qt_fstatx(int, statx*)’:
    io/qfilesystemengine_unix.cpp:331:34: error: ‘AT_EMPTY_PATH’ was not declared in this scope
      331 |     return qt_real_statx(fd, "", AT_EMPTY_PATH, statxBuffer);
          |                                  ^~~~~~~~~~~~~
    io/qfilesystemengine_unix.cpp: In static member function ‘static bool QFileSystemEngine::renameFile(const QFileSystemEntry&, const QFileSystemEntry&, QSystemError&)’:
    io/qfilesystemengine_unix.cpp:1447:19: error: ‘AT_FDCWD’ was not declared in this scope
     1447 |     if (renameat2(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_NOREPLACE) == 0)
          |                   ^~~~~~~~
    

    I've read AT_ macros are defined in fcntl.h, and when i try to compile a simple program that uses those macros it works without any problems.

    My sysroot dir contains /lib /usr/lib /usr/include and /opt/vc/ from my rpi.

    I've found this thread on QT forums:
    https://forum.qt.io/topic/97290/cross-compiling-on-ubuntu-to-rpi-b-raspbian-stretch

    but I dont understand the solution posted there - I've tried changing my configure script accordingly and unfortunately it failed with same error.
    I'd be very thankful for any help.



  • Figured it out finally. The original compiler from rpi toolchain didn't work for some reason, and my own compiler was built without

    --enable-multiarch
    

    Adding this parameter to gcc configure script finally solved the problem.


Log in to reply