简体   繁体   English

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

[英]Cmake toolchain for 32-bit MIPS processor

Need to run an Azure IoT SDK C sample on an Axis camera. 需要在Axis相机上运行Azure IoT SDK C示例。 Using the standard cmake to build the samples does not work, as they are compiled for 64-bit x86_84. 使用标准cmake构建示例不起作用,因为它们是针对64位x86_84进行编译的。 Need it to be compiled to MIPS32. 需要将其编译为MIPS32。

Eugene Sh. 尤金 suggested making a toolchain file for it. 建议为其制作工具链文件。 I've written one now, but it fails at 16% with the following error: 我现在已经写了一个,但是失败了,但出现以下错误: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

My toolchain file: 我的工具链文件:

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)

And run it using ´./build.sh --toolchain-file toolchain-mips.cmake`. 并使用´。/ build.sh --toolchain-file toolchain-mips.cmake`运行它。

If I run it as the documentation says, using -cl --sysroot=/usr/local/mipsisa32r2el/r23. 如果我按照文档所述运行它,请使用-cl --sysroot = / usr / local / mipsisa32r2el / r23。 I get errors that it cannot find OpenSSL and fails much earlier. 我收到无法找到OpenSSL的错误,并且失败得多。

Figured out part of it. 找出其中的一部分。 It cannot find OpenSSL because it's not in the specified root folder. 它找不到OpenSSL,因为它不在指定的根文件夹中。 Obvious enough, really. 很明显,真的。 Required cloning the source and building using mips gcc and providing the path to its root as well. 需要克隆源代码并使用mips gcc进行构建,并提供指向其根目录的路径。

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

Then the same thing for Curl. 然后对于Curl也是如此。

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

And now I'm mostly back to where I started. 现在,我基本上回到了起点。 Missing header files that I'm not entirely where I should place. 缺少标头文件,但我并不完全应该放置该文件。 A new issue, however, is when running the build script with the --sysroot=/usr/local/mipsisa32r2el/r23 suffix, it fails at 0% citing that warnings are treated as errors. 但是,一个新问题是,当运行带有--sysroot=/usr/local/mipsisa32r2el/r23后缀的构建脚本时,它会以0%的速度失败,原因是将警告视为错误。 Considering this does not happen without the suffix, I can only assume it has something to do with the provided mips-related files and not the CMake files. 考虑到没有后缀就不会发生这种情况,我只能假定它与提供的与mips相关的文件有关,而不与CMake文件有关。

EDIT: Managed to fix it and successfully build using the toolchain. 编辑:设法修复它并成功使用工具链进行构建。

Skipped the sysroot argument. 跳过sysroot参数。 Resolved an error about missing header files for uuid . 解决了有关uuid缺少头文件的错误。

At 22% I the following error, which was discussed and solved here. 在22%的情况下,出现以下错误,在此进行了讨论和解决。 . Short answer, built only uuid from util-linux. 简短的答案,仅从util-linux构建uuid。

Finally, I was able to build via Cmake for my MIPS-32 device. 最终,我能够通过Cmake为我的MIPS-32设备进行构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM