clang: error: linker command failed with exit code 1

Question

. /opt/os-sdk/16.0.0-aarch64/environment-setup-aarch64-os-linux
$ flutter-elinux create helloworld
Recreating project helloworld...

$ cd helloworld/


$ flutter-elinux build elinux --target-arch=arm64 \
>      --target-compiler-triple=aarch64-os-linux \
>      --target-sysroot=/opt/os-sdk/16.0.0-aarch64/sysroots/aarch64-os-linux

Building an eLinux application with wayland backend in release mode for arm64 target...            ⡿
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1336 bytes (99.9% reduction). Tree-shaking can be disabled by
providing the --no-tree-shake-icons flag when building your app.
Building an eLinux application with wayland backend in release mode for arm64 target...        15.3s
Failed to cmake:
-- Toolchain file defaulted to '/opt/os-sdk/16.0.0-aarch64/sysroots/x86_64-ossdk-linux/usr/share/cmake/OEToolchainConfig.cmake'
-- The CXX compiler identification is Clang 10.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ - broken
-- Configuring incomplete, errors occurred!
See also "/home/baifudong/project/rk3326/sdk/helloworld/build/elinux/arm64/release/CMakeFiles/CMakeOutput.log".
See also "/home/baifudong/project/rk3326/sdk/helloworld/build/elinux/arm64/release/CMakeFiles/CMakeError.log".

CMake Error at /opt/os-sdk/16.0.0-aarch64/sysroots/x86_64-ossdk-linux/usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/usr/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/baifudong/project/rk3326/sdk/helloworld/build/elinux/arm64/release/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/local/bin/make -f Makefile cmTC_dc5d4/fast && /usr/local/bin/make  -f CMakeFiles/cmTC_dc5d4.dir/build.make
    CMakeFiles/cmTC_dc5d4.dir/build
    make[1]: Entering directory '/home/baifudong/project/rk3326/sdk/helloworld/build/elinux/arm64/release/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_dc5d4.dir/testCXXCompiler.cxx.o
    /usr/bin/clang++ --target=aarch64-os-linux --sysroot=/opt/os-sdk/16.0.0-aarch64/sysroots/aarch64-os-linux   -O2 -pipe -g
    -feliminate-unused-debug-types   -MD -MT CMakeFiles/cmTC_dc5d4.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_dc5d4.dir/testCXXCompiler.cxx.o.d
    -o CMakeFiles/cmTC_dc5d4.dir/testCXXCompiler.cxx.o -c
    /home/baifudong/project/rk3326/sdk/helloworld/build/elinux/arm64/release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    Linking CXX executable cmTC_dc5d4
    /opt/os-sdk/16.0.0-aarch64/sysroots/x86_64-ossdk-linux/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_dc5d4.dir/link.txt --verbose=1
    /usr/bin/clang++ --target=aarch64-os-linux --sysroot=/opt/os-sdk/16.0.0-aarch64/sysroots/aarch64-os-linux  -O2 -pipe -g
    -feliminate-unused-debug-types   -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed  -Wl,-z,relro,-z,now
    CMakeFiles/cmTC_dc5d4.dir/testCXXCompiler.cxx.o -o cmTC_dc5d4
    /usr/bin/ld: unrecognised emulation mode: aarch64linux
    Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [CMakeFiles/cmTC_dc5d4.dir/build.make:100: cmTC_dc5d4] Error 1
    make[1]: Leaving directory '/home/baifudong/project/rk3326/sdk/helloworld/build/elinux/arm64/release/CMakeFiles/CMakeTmp'
    make: *** [Makefile:127: cmTC_dc5d4/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:4 (project)

Answer

Build yocto sdk with clang support

Add the following in your conf/local.conf:

CLANGSDK = "1"
0%