用于 32 位 MIPS 处理器的 Cmake 工具链

Cmake toolchain for 32-bit MIPS processor

需要 运行 Axis 相机上的 Azure IoT SDK C 示例。使用标准 cmake 构建示例不起作用,因为它们是为 64 位 x86_84 编译的。需要编译成MIPS32。

Eugene Sh。建议为它制作一个工具链文件。我现在已经写了一个,但在 16% 时失败并出现以下错误:

[ 16%] /usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
Building C object c-utility/CMakeFiles/aziotsharedutil.dir/adapters/uniqueid_linux.c.o
/demo/azure-iot-sdk-c/c-utility/adapters/uniqueid_linux.c:7:23: fatal error: uuid/uuid.h: No such file or directory
compilation terminated.
make[2]: *** [c-utility/CMakeFiles/aziotsharedutil.dir/adapters/uniqueid_linux.c.o] Error 1
make[1]: *** [c-utility/CMakeFiles/aziotsharedutil.dir/all] Error 2
make: *** [all] Error 2

我的工具链文件:

INCLUDE(CMakeForceCompiler)

SET(CMAKE_SYSTEM_NAME Linux)     # this one is important
SET(CMAKE_SYSTEM_VERSION 1)      # this one not so much
SET(CMAKE_SYSTEM_PROCESSOR mips)

# this is the location of the imps toolchain targeting the M1125
SET(CMAKE_C_COMPILER /usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc)

# this is the file system root of the target
#SET(CMAKE_FIND_ROOT_PATH /usr/local/mipsisa32r2el/r23)

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

# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

并且 运行 它使用 ´./build.sh --toolchain-file toolchain-mips.cmake`。

如果我 运行 如 documentation 所说,使用 -cl --sysroot=/usr/local/mipsisa32r2el/r23。我得到的错误是它找不到 OpenSSL 并且失败得更早。

想出了一部分。它找不到 OpenSSL,因为它不在指定的根文件夹中。很明显,真的。需要克隆源代码并使用 mips gcc 构建并提供其根目录的路径。

SET(CMAKE_FIND_ROOT_PATH /path/to/mips/openssl /usr/local/mipsisa32r2el/r23)

Curl 也是如此。

SET(CMAKE_FIND_ROOT_PATH /path/to/mips/openssl /path/to/mips/curl /usr/local/mipsisa32r2el/r23)

现在我基本上回到了开始的地方。缺少我不完全应该放置的头文件。然而,一个新问题是当 运行 带有 --sysroot=/usr/local/mipsisa32r2el/r23 后缀的构建脚本时,它在 0% 时失败,理由是警告被视为错误。考虑到没有后缀就不会发生这种情况,我只能假设它与提供的 mips-related 文件有关,而不是与 CMake 文件有关。

编辑:设法修复它并使用工具链成功构建。

跳过了 sysroot 参数。解决了 uuid 缺少头文件的错误。

在 22% 时出现以下错误,即 。简短回答,仅从 util-linux.

构建 uuid

最后,我能够通过 Cmake 为我的 MIPS-32 设备构建。