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

What is mkspecs used for & how to configure for my hardware



  • Dear fellow coders, I've followed through instructions to configure, make and make install the source files. However what exactly is the mkspecs for / used for? and if I've a generic embedded Linux board, what information I'd need to include in my qmake.conf file before executing ./configure command to start configuring and later compiling all the sources?



  • @embdev said in What is mkspecs used for & how to configure for my hardware:

    Dear fellow coders, I've followed through instructions to configure, make and make install the source files. However what exactly is the mkspecs for / used for? and if I've a generic embedded Linux board, what information I'd need to include in my qmake.conf file before executing ./configure command to start configuring and later compiling all the sources?

    a makespec is a set of compilation rules. What is the compiler called? What arguments does it need?

    Pulling from a random example, the solaris-cc qmake.conf tells me that the C++ compiler (QMAKE_CXX) is called CC. The standard C++ compiler flags are the same as the C compiler flags, QMAKE_CFLAGS.

    The usual mode of operation for a platform that is similar to an existing and supported platform is to import an existing mkspec and modify where necessary. The modified mkspec is placed in <Qt source>/qtbase/mkspecs/<platform>, and passed to configure using -platform or -xplatform.



  • i see. so let's say i've a generic embedded Linux board that's listed in the device, what are the additional commands I need to include in the qmake.conf file before I start compiling?

    In the following example, i've appended "-hisiv400-" to indicate my hardware. Is this sufficient?

    qmake configuration for building with arm-hisiv400-linux-g++

    include(../../common/linux.conf)
    include(../../common/gcc-base-unix.conf)
    include(../../common/g++-unix.conf)
    include(../../common/qws.conf)

    modifications to g++.conf

    QMAKE_CC = arm-hisiv400-linux-gcc
    QMAKE_CXX = arm-hisiv400-linux-g++
    QMAKE_LINK = arm-hisiv400-linux-g++
    QMAKE_LINK_SHLIB = arm-hisiv400-linux-g++

    modifications to linux.conf

    QMAKE_AR = arm-hisiv400-linux-ar cqs
    QMAKE_OBJCOPY = arm-hisiv400-linux-objcopy
    QMAKE_STRIP = arm-hisiv400-linux-strip

    load(qt_config)


  • Lifetime Qt Champion

    Hi,

    If you have a cross-toolchain that is arm-hisiv400-linux- then yes, you should be good to go. Just make sure that you can call the executable from the command line where you will cross-compile Qt.



  • Actually by cross-compiling Qt, i'll be able to get the qmake.exe for my target device right?

    Perhaps i'll give an overview of what I've done so far:

    1. Installed Qt 5.7 in 64-bit Ubuntu (virtualbox)
    2. Downloaded Qt 5.7 sources
    3. Created a folder in /qtbase/mkspecs/devices/Linux-arm-hi3536-g++ and copied qmake-conf file from other folders in /devices
    4. Amended qmake.conf to customize for my target embedded Linux device with the following commands:

    QMAKE_INCDIR += /usr/include
    QMAKE_INCDIR += /usr/include
    HISILICON_CFLAGS += -march=armv7-a -mcpu=cortex-a9
    QMAKE_CFLAGS += $$HILICON_FLAGS
    QMAKE_CXXFLAGS += $$HILICON_FLAGS

    1. Created a compile.sh file to include my ./configure parameters so I can run the compile.sh file instead of typing ./configure followed by the parameters. My parameters for my target device are:

    #/bin/bash

    ./configure -confirm-license -release -eglfs -v -static -device linux-arm-hi3536-g++ -device-option CROSS_COMPILE=/opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/arm-hisiv400-linux-gnueabi- -sysroot /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -prefix /home/aa/Hi3536_SDK_V2.0.4.0/v1_QtEmbedded_5.7

    1. When I run ./compile.sh script (with my ./configure parameters in it) in the terminal, I encountered the following error:

    DEFAULT_INCDIRS="/opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/arm-hisiv400-linux-gnueabi
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/backward
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/include
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/include-fixed
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include
    "
    DEFAULT_LIBDIRS="/opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/lib
    /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single/lib
    /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single/usr/lib
    "
    Creating qmake...
    make: Nothing to be done for 'first'.
    Running configuration tests...
    Found pkg-config from $PATH: /usr/bin/pkg-config
    Warning: Disabling pkg-config since PKG_CONFIG_LIBDIR is not set and
    the host's .pc files would be used (even if you set PKG_CONFIG_PATH).
    Set this variable to the directory that contains target .pc files
    for pkg-config to function correctly when cross-compiling or
    use -pkg-config to override this test.
    Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single
    Determining architecture... ()
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/arm-hisiv400-linux-gnueabi-g++ -c -pipe -mfloat-abi=hard --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -g -Wall -W -fPIC -I. -I/usr/include -I../../mkspecs/devices/linux-arm-hi3536-g++ -o arch.o arch.cpp
    In file included from /usr/include/stdio.h:27:0,
    from arch.cpp:43:
    /usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory

    include <sys/cdefs.h>

                         ^
    

    compilation terminated.
    Makefile:208: recipe for target 'arch.o' failed
    make: *** [arch.o] Error 1
    Unable to determine architecture!

    Could not determine the target architecture!
    Turn on verbose messaging (-v) to see the final report.
    Determining architecture... ()
    g++ -c -pipe -g -Wall -W -fPIC -I. -I../../mkspecs/linux-g++ -o arch.o arch.cpp
    g++ -o arch arch.o
    Found architecture in binary
    CFG_HOST_ARCH="x86_64"
    CFG_HOST_CPUFEATURES=" mmx sse sse2"
    System architecture: 'unknown'
    Host architecture: 'x86_64'
    Precompiled-headers support enabled.
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/arm-hisiv400-linux-gnueabi-g++ -c -fvisibility=hidden fvisibility.c
    Symbol visibility control enabled.
    collect2: fatal error: cannot find 'ld'
    compilation terminated.
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/arm-hisiv400-linux-gnueabi-g++ --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -o libtest.so -shared -Wl,-Bsymbolic-functions -fPIC bsymbolic_functions.c
    bsymbolic_functions.c:2:2: error: #error "Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129)."
    #error "Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129)."
    ^
    Symbolic function binding disabled.
    checking for C++11...
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/arm-hisiv400-linux-gnueabi-g++ -c -pipe -mfloat-abi=hard --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -O2 -std=gnu++11 -Wall -W -fPIC -I. -I/usr/include -I../../../mkspecs/devices/linux-arm-hi3536-g++ -o c++11.o c++11.cpp
    In file included from /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/arm-hisiv400-linux-gnueabi/bits/os_defines.h:39:0,
    from /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/arm-hisiv400-linux-gnueabi/bits/c++config.h:426,
    from /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/utility:68,
    from c++11.cpp:46:
    /usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory

    include <sys/cdefs.h>

                         ^
    

    compilation terminated.
    Makefile:195: recipe for target 'c++11.o' failed
    make: *** [c++11.o] Error 1
    C++11 disabled.
    ERROR: Qt requires a C++11 compiler and yours does not seem to be that.
    Please upgrade.

    I know it's a long list but would greatly appreciate if you guys can just drop any comments you know.

    Essentially, I want to create the qmake.exe so I can include into my kit and perform my software development work in Qt Creator IDE itself.

    Thank you very much!


  • Lifetime Qt Champion

    Are you sure that your sysroot provides the dependencies needed for your target ?



  • @SGaist that's pretty much a valid note. Maybe that's not the correct sysroot path or incomplete. Is sysroot normally supplied in SDK or I need to build one myself? Does it resides normally in the kernel files that comes with the SDK itself? How may I determine if the sysroot provides the necessary dependencies?



  • Perhaps the compiler needs "-std=c++11" in QMAKE_CXXFLAGS.



  • could it be due to my vendor supplied compiler? I think it's a 32-bit compiler.



  • Never mind about the -std flag. I see "-std=gnu++11".

    cdefs.h shouldn't be missing due to being a 32 bit compiler. The version I have comes from a glibc-headers x86_64 package. Can you find a copy of the file in the sysroot, and is that location in the include path passed to the compiler with -I?



  • the error log says it's unable to determine my target architecture and also something about c++11. Do I need to amend my qmake.conf file to do something about these 2 parameters mentioned above?

    For the sysroot, i'm only able to locate rootfs in my SDK itself. Would it be ok to use the rootfs path in my configure line?



  • Hi @jeremy_k , could you elaborate by -l ?



  • -I, as in -I../../../mkspecs/devices/linux-arm-hi3536-g++, specifies an include path to search.



  • @jeremy_k I see. Actually I went to study my CC directory again installed in /opt/ and managed to locate the missing files as mentioned above.

    (1) I therefore amended my qmake.conf paths to the following directories:

    ----------- qmake.conf --------------------------------------------------------------------------------------------------------

    QMAKE_INCDIR += /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/include
    QMAKE_LIBDIR += /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/lib
    QMAKE_LIBDIR += /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/lib

    -------------------------------------------------------------------------------------------------------------------------------

    (2) My configure script are as follows

    ---- configure script ----------------------------------------------------------------------------------------------------------------------

    ./configure -confirm-license -release -eglfs -v -static -device linux-arm-hi3536-g++ -device-option CROSS_COMPILE=/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux- -sysroot /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -prefix /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single/home/aa/Hi3536_SDK_V2.0.4.0/v1_QtEmbedded_5.7

    --------------------------------------------------------------------------------------------------------------------------------------

    (3) I proceed to build my Qt 5.7 sources again with the configure script above and the errors reduced drastically to only about a page's worth of errors:

    -------Build error messages from terminal -------------------------------------------------------------------------------------

    a@aa:~/Hi3536_SDK_V2.0.4.0/qt-everywhere-enterprise-src-5.7.0/qtbase$ ./build5.7_22-SEPT-16.sh
    This is the Qt Device Creation Edition.

    DEFAULT_INCDIRS="/opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/arm-hisiv400-linux-gnueabi
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/backward
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/include
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/include-fixed
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include
    "
    DEFAULT_LIBDIRS="/opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/lib/gcc
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/lib
    /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single/lib
    /home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single/usr/lib
    "
    Creating qmake...
    make: Nothing to be done for 'first'.
    Running configuration tests...
    Determining architecture... ()
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++ -c -pipe -mfloat-abi=hard --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -g -Wall -W -fPIC -I. -isystem /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/include -I../../mkspecs/devices/linux-arm-hi3536-g++ -o arch.o arch.cpp
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++ -mfloat-abi=hard -o arch arch.o -L/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/lib -L/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/lib -lrt --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find crt1.o: No such file or directory
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status
    Makefile:91: recipe for target 'arch' failed
    make: *** [arch] Error 1
    Unable to determine architecture!

    Could not determine the target architecture!
    Turn on verbose messaging (-v) to see the final report.
    Determining architecture... ()
    g++ -c -pipe -g -Wall -W -fPIC -I. -I../../mkspecs/linux-g++ -o arch.o arch.cpp
    g++ -o arch arch.o
    Found architecture in binary
    CFG_HOST_ARCH="x86_64"
    CFG_HOST_CPUFEATURES=" mmx sse sse2"
    System architecture: 'unknown'
    Host architecture: 'x86_64'
    Precompiled-headers support enabled.
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++ -c -fvisibility=hidden fvisibility.c
    Symbol visibility control enabled.
    collect2: fatal error: cannot find 'ld'
    compilation terminated.
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++ --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -o libtest.so -shared -Wl,-Bsymbolic-functions -fPIC bsymbolic_functions.c
    bsymbolic_functions.c:2:2: error: #error "Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129)."
    #error "Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129)."
    ^
    Symbolic function binding disabled.
    checking for C++11...
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++ -c -pipe -mfloat-abi=hard --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single -O2 -std=gnu++11 -Wall -W -fPIC -I. -isystem /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/include -I../../../mkspecs/devices/linux-arm-hi3536-g++ -o c++11.o c++11.cpp
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++ -mfloat-abi=hard -Wl,-O1 -o c++11 c++11.o -L/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/lib -L/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/lib -lrt --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find crt1.o: No such file or directory
    /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status
    Makefile:91: recipe for target 'c++11' failed
    make: *** [c++11] Error 1
    C++11 disabled.
    ERROR: Qt requires a C++11 compiler and yours does not seem to be that.
    Please upgrade.

    ----------------------------------------------------------------------------------------------------------------------------------------

    (4) Would you be able to provide some advice from here? I believe i'm pretty close to closing the errors


  • Lifetime Qt Champion

    What does linux-arm-hi3536-g++ --version return ?



  • @SGaist [linux-arm-hi3536-g++] is the folder I created in Qt, the compiler is arm-hisiv400-linux-g++ installed in /opt/. The version is as follows:

    arm-hisiv400-linux-g++ (Hisilicon_v400) 4.8.3 20131202 (prerelease)
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


  • Lifetime Qt Champion

    Can you take a look in your cross-compiler folder and search for where crti.o is ?



  • @SGaist actually I found the directory for crt1.o and crti.o. Do you know how to link to the correct directory for these 2 libs?


  • Lifetime Qt Champion

    Where is that file located ?



  • @SGaist it's stored in /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/lib inside my toolchain installed on the host PC.


  • Lifetime Qt Champion

    Strange path...

    You can add it to your configure line with -L /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/lib



  • @SGaist actually from the error log above, this path is already included inside but i'm not sure why during the search (in the following command lines) that particular path containing the 2 object files are not searched:

    -L/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/usr/lib -L/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/lib -lrt --sysroot=/home/aa/Hi3536_SDK_V2.0.4.0/package/osdrv_single/rootfs_glibc_single
     /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find crt1.o: No such file or directory
     /opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory
    

  • Lifetime Qt Champion

    Strange... Did you re-run configure ? If so, did you do it from a clean state ?



  • @SGaist actually removing the sysroot, allows me to configure the file, also did some changes to the QMAKE paths to the lib and include. Is the sysroot important?


  • Lifetime Qt Champion

    It's usually the sysroot that provides all the dev packages for the dependencies you might need when cross-compiling. The dependencies that are not part of the cross-toolchain that is.


Log in to reply