cmake 交叉编译错误|'_Float128'没有命名类型;您的意思是'_Float32x'吗?

busg9geu  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(514)

我在使用cmake交叉编译应用程序时遇到了一个问题。我使用基于外部Buildroot的SDK为其中一个项目进行交叉编译。它是基于“aarch64”的,我有其他基于“arm”的SDK,它们编译时没有任何错误。
使用cmake ../. -DCMAKE_TOOLCHAIN_FILE=[...]/ToolchainFile.cmake编译成功,它从C和CXX编译器的SDK获取正确的路径。但是当我运行make时,我得到以下错误:

In file included from /opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/wchar.h:30,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cwchar:44,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/postypes.h:40,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/char_traits.h:40,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:40,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/usr/include/x86_64-linux-gnu/bits/floatn.h:87:9: error: '__float128' does not name a type; did you mean '__cfloat128'?
   87 | typedef __float128 _Float128;
      |         ^~~~~~~~~~
      |         __cfloat128
In file included from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cwchar:44,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/postypes.h:40,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/char_traits.h:40,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:40,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/wchar.h:406:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
  406 | extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/wchar.h:523:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
  523 | extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
In file included from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cstdlib:75,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/ext/string_conversions.h:41,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6496,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:55,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdlib.h:152:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
  152 | extern _Float128 strtof128 (const char *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdlib.h:245:4: error: '_Float128' has not been declared
  245 |    _Float128 __f)
      |    ^~~~~~~~~
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdlib.h:330:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
  330 | extern _Float128 strtof128_l (const char *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
In file included from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cstdlib:75,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/ext/string_conversions.h:41,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6496,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:55,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdlib.h:935:5: error: expected initializer before '__attr_access'
  935 |     __attr_access ((__read_only__, 2));
      |     ^~~~~~~~~~~~~
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdlib.h:940:3: error: expected initializer before '__attr_access'
  940 |   __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
      |   ^~~~~~~~~~~~~
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdlib.h:994:30: error: expected initializer before '__attr_access'
  994 |      __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
      |                              ^~~~~~~~~~~~~
In file included from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/ext/string_conversions.h:41,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6496,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:55,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cstdlib:154:11: error: '::mbstowcs' has not been declared
  154 |   using ::mbstowcs;
      |           ^~~~~~~~
/opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cstdlib:171:11: error: '::wcstombs' has not been declared
  171 |   using ::wcstombs;
      |           ^~~~~~~~
In file included from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cstdio:42,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/ext/string_conversions.h:43,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6496,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:55,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdio.h:569:12: error: expected initializer before '__attr_access'
  569 |      __wur __attr_access ((__write_only__, 1, 2));
      |            ^~~~~~~~~~~~~
/opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdio.h:593:5: error: expected initializer before '__attr_access'
  593 |     __attr_access ((__write_only__, 1, 2));
      |     ^~~~~~~~~~~~~
In file included from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/ext/string_conversions.h:43,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6496,
                 from /opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/string:55,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:27,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/cstdio:108:11: error: '::fgets' has not been declared
  108 |   using ::fgets;
      |           ^~~~~
In file included from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/include/Action.hpp:29,
                 from /root/sources/aarch64/aws-iot-client/lib/aws-iot-device-sdk-cpp/src/Action.cpp:26:
/opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/memory: In function 'void* std::align(std::size_t, std::size_t, void*&, std::size_t&)':
/opt/sdk_mmia53.e2c-demo.640/opt/ext-toolchain/aarch64-buildroot-linux-gnu/include/c++/9.4.0/memory:121:58: error: cast from 'void*' to 'uintptr_t' {aka 'unsigned int'} loses precision [-fpermissive]
  121 |   const auto __intptr = reinterpret_cast<uintptr_t>(__ptr);
      |                                                          ^
make[2]: *** [lib/aws-iot-device-sdk-cpp/CMakeFiles/aws-iot-sdk-cpp.dir/build.make:66: lib/aws-iot-device-sdk-cpp/CMakeFiles/aws-iot-sdk-cpp.dir/src/Action.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:341: lib/aws-iot-device-sdk-cpp/CMakeFiles/aws-iot-sdk-cpp.dir/all] Error 2
make: *** [Makefile:133: all] Error 2

字符串
我不明白这个错误的原因是什么,而它成功地为“arm”SDK构建。

ToolchainFile.cmake
# General CMAKE cross compile settings
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_SYSTEM_VERSION 1)

# Specify Sysroot path
SET(CMAKE_SYSROOT /opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/)

# Specify path to find filesystem items
SET(CMAKE_FIND_ROOT_PATH /opt/sdk_mmia53.e2c-demo.640/aarch64-buildroot-linux-gnu/sysroot/)

# Search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# Specify toolchain directory
SET(TOOLCHAIN_DIR /opt/sdk_mmia53.e2c-demo.640/bin/)

# Specify cross compilation target
SET(TARGET_CROSS aarch64-linux-)

# Set compilers
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/${TARGET_CROSS}g++)

# Set linker
SET(CMAKE_LINKER ${TOOLCHAIN_DIR}/${TARGET_CROSS}ld)

# Set compiler flags
SET(CMAKE_CXX_FLAGS ${COMMON_FLAGS} -std=c++11)

# Set archiving tool
SET(CMAKE_AR ${TOOLCHAIN_DIR}/${TARGET_CROSS}ar CACHE FILEPATH "Archiver")

# Set randomizing tool for static libraries
SET(CMAKE_RANLIB ${TOOLCHAIN_DIR}/${TARGET_CROSS}ranlib)

# Set strip tool
SET(CMAKE_STRIP ${TOOLCHAIN_DIR}/${TARGET_CROSS}strip)

# Set objdump tool
SET(CMAKE_OBJDUMP ${TOOLCHAIN_DIR}/${TARGET_CROSS}objdump)

# Set objcopy tool
SET(CMAKE_OBJCOPY ${TOOLCHAIN_DIR}/${TARGET_CROSS}objcopy)

# Set nm tool
SET(CMAKE_NM ${TOOLCHAIN_DIR}/${TARGET_CROSS}nm)

# Set THREADS_PTHREAD_ARG for testing threading
SET(THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by ToolchainFile.cmake." FORCE)

的数据
CMakeCache.txt中,所有路径都是从SDK获取的,而不是从构建系统获取的
有人能告诉我如何解决这个问题吗?
你的帮助将不胜感激。
Thanks in advance
我用的是Ubuntu 20.04,如果有任何信息丢失,请告诉我。

unhi4e5o

unhi4e5o1#

x86_64-linux-gnu是您不希望在aarch64构建中看到的东西,但您使用x86_64-linux-gnu/bits/floatn.h
你需要弄清楚它是如何潜入的。你的SDK到底在哪里从它的目录中分离出来并使用一个非SDK头?

相关问题