This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM62A7-Q1: cmake build error

Genius 13655 points
Part Number: AM62A7-Q1

Hello Champs,

1. Below is the main.c:

#include <stdio.h>

int main(void)
{
printf("Hello World\n");
return 0;
}

2. Below is the CMakeLists.txt:

cmake_minimum_required (VERSION 2.8)

project (demo)

add_executable(main main.c)

3.Build error:

[linux-devkit]:/home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/hawk> make
[ 50%] Building C object CMakeFiles/main.dir/main.c.o
In file included from /home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/aarch64-oe-linux/usr/include/features-time64.h:21,
from /home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/aarch64-oe-linux/usr/include/features.h:392,
from /home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/aarch64-oe-linux/usr/include/bits/libc-header-start.h:33,
from /home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/aarch64-oe-linux/usr/include/stdio.h:27,
from /home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/hawk/main.c:1:
/home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/aarch64-oe-linux/usr/include/bits/timesize.h:23:10: fatal error: bits/timesize-32.h: 没有那个文件或目录
23 | #include <bits/timesize-32.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/main.dir/build.make:76:CMakeFiles/main.dir/main.c.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/main.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2



Thanks
Regards
Shine

  • Looks like `cmake` results in the build system trying to attempt a 32-bit build instead of a 64-bit build which the devkit you are using is intended for. If you look at the respective header file you'll see the the inclusion of timesize-32.h is only attempted when __WORDSIZE == 32, so somebody is setting this...

    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#include <bits/wordsize.h>
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#if __WORDSIZE == 32
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#ifdef _MIPS_SIM
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#if _MIPS_SIM == _ABIO32
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h:#include <bits/timesize-32.h>
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#elif _MIPS_SIM == _ABIN32
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#include <bits/timesize-n32.h>
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#else
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#error "Unknown _MIPS_SIM"
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#endif
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#else /* _MIPS_SIM is not defined */
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h:#include <bits/timesize-32.h>
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#endif
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-
    sysroots/aarch64-oe-linux/usr/include/bits/timesize.h-#elif __WORDSIZE == 64

    Cmake has an option to force a target architecture called CMAKE_GENERATOR_PLATFORM, see https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_PLATFORM.html#variable:CMAKE_GENERATOR_PLATFORM

    Can you try something like the below and see if this helps and report back here:

    cmake . -DCMAKE_GENERATOR_PLATFORM=ARM64

    Regards, Andreas

  • Hello Andreas,

    Thank you very much for your great support.

    Customer found that it may be caused by a cross-compilation environment that does not support 32-bit compilation:

    Set (CMAKE_C_COMPILER) "${TOOLCHAIN_DIR}/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc")
    set (CMAKE_CXX_COMPILER) "${TOOLCHAIN_DIR}/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++")

    The search path for header files is set as follows:

    set(INCLUDE_PATH) ${CMAKE_SYSROOT}/x86_64-arago-linux/usr/lib/aarch64-oe-linux/gcc/aarch64-oe-linux/11.4.0/include)

    Both CMAKE_SYSROOT and TOOLCHAIN_DIR correspond to the following paths:

    Sdk installation directory \linux-devkit\sysroots

    What needs to be confirmed now focus on below 4 issues:

    1.Does the SDK environment only support compilation of 64-bit targets?

    2. Is the ubuntu22.04 virtual machine on win10 cross-compile using the compilation tool under x86_64-arago-linux?

    3. Is the search path setting for the header files correct? Does he need to confirm the g++ header files search path, otherwise he cannot compile the file for cpp?

    4.In order to compile 64-bit targets, how to configure the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS?


    Thanks
    Regards
    Shine

  • BTW,  customer executed cmake according to your advice. It prompts below errors

    [linux-devkit]:/home/qingfeng/workspace/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/hawk> cmake . -B build -DCMAKE_GENERATOR_PLATFORM=ARM64 -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchains/aarch64_linux_buildroot.cmake
    CMake Error at CMakeLists.txt:3 (PROJECT):
    Generator

    Unix Makefiles

    does not support platform specification, but platform

    ARM64

    was specified.

    By reading the link below:
    https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_PLATFORM.html#variable:CMAKE_GENERATOR_PLATFORM

    It can be concluded that setting the CMAKE_GENERATOR_PLATFORM variable is for specific generators. For example, Visual Studio Generators.

    But the problem customer facing now is that the linux-devkit based on sdk builds a cross-compilation environment.

    Thanks
    Regards
    Shine

  • Let me find some time to look into this a bit more closely and get back to you.

    Regards, Andreas

  • Hi Andreas,

    Okay. 

    Thank you very much.

    Regards
    Shine

  • Hi Shine,

    I tried building your CMake-based example in the context of the Linux devkit part of AM62A SDK v9.1 and had no issues. Please see log below. You can see how the aarch64 binary output file 'main' was generated successully.

    a0797059@dasso:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit
    $ source ./environment-setup
    
    [linux-devkit]:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit> cd tmp/
    
    [linux-devkit]:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/tmp> cmake CMakeLists.txt
    CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
      Compatibility with CMake < 2.8.12 will be removed from a future version of
      CMake.
    
      Update the VERSION argument <min> value or use a ...<max> suffix to tell
      CMake that the project does not need compatibility with older versions.
    
    
    -- Toolchain file defaulted to '/home/a0797059/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/x86_64-arago-linux/usr/share/cmake/OEToolchainConfig.cmake'
    -- The C compiler identification is GNU 11.4.0
    -- The CXX compiler identification is GNU 11.4.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /home/a0797059/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-
    gcc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /home/a0797059/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linu
    x-g++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/a0797059/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/tmp
    
    [linux-devkit]:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/tmp> ll
    total 52
    drwxrwxr-x 3 a0797059 a0797059  4096 Feb  5 12:35 ./
    drwxr-xr-x 4 a0797059 a0797059  4096 Feb  5 12:34 ../
    -rw-rw-r-- 1 a0797059 a0797059 18261 Feb  5 12:35 CMakeCache.txt
    drwxrwxr-x 5 a0797059 a0797059  4096 Feb  5 12:35 CMakeFiles/
    -rw-rw-r-- 1 a0797059 a0797059  1891 Feb  5 12:35 cmake_install.cmake
    -rw-rw-r-- 1 a0797059 a0797059    83 Feb  5 12:34 CMakeLists.txt
    -rw-rw-r-- 1 a0797059 a0797059    90 Feb  5 12:34 main.c
    -rw-rw-r-- 1 a0797059 a0797059  5793 Feb  5 12:35 Makefile
    
    [linux-devkit]:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/tmp> make
    [ 50%] Building C object CMakeFiles/main.dir/main.c.o
    [100%] Linking C executable main
    [100%] Built target main
    
    [linux-devkit]:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/tmp> ll
    total 68
    drwxrwxr-x 3 a0797059 a0797059  4096 Feb  5 12:35 ./
    drwxr-xr-x 4 a0797059 a0797059  4096 Feb  5 12:34 ../
    -rw-rw-r-- 1 a0797059 a0797059 18261 Feb  5 12:35 CMakeCache.txt
    drwxrwxr-x 5 a0797059 a0797059  4096 Feb  5 12:35 CMakeFiles/
    -rw-rw-r-- 1 a0797059 a0797059  1891 Feb  5 12:35 cmake_install.cmake
    -rw-rw-r-- 1 a0797059 a0797059    83 Feb  5 12:34 CMakeLists.txt
    -rwxrwxr-x 1 a0797059 a0797059 15536 Feb  5 12:35 main*
    -rw-rw-r-- 1 a0797059 a0797059    90 Feb  5 12:34 main.c
    -rw-rw-r-- 1 a0797059 a0797059  5793 Feb  5 12:35 Makefile
    
    [linux-devkit]:~/ti/ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/linux-devkit/tmp> file main
    main: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=123cbf73df0ae93094777ad6ceddc62ff1861c1b, for GNU/Linux 3.14.0, with debug_info, not stripped

    Regards, Andreas