简体   繁体   中英

Cmake toolchain for 32-bit MIPS processor

Need to run an Azure IoT SDK C sample on an Axis camera. Using the standard cmake to build the samples does not work, as they are compiled for 64-bit x86_84. Need it to be compiled to 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%] /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`.

If I run it as the documentation says, using -cl --sysroot=/usr/local/mipsisa32r2el/r23. I get errors that it cannot find OpenSSL and fails much earlier.

Figured out part of it. It cannot find OpenSSL because it's not in the specified root folder. Obvious enough, really. Required cloning the source and building using mips gcc and providing the path to its root as well.

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

Then the same thing for 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. 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.

EDIT: Managed to fix it and successfully build using the toolchain.

Skipped the sysroot argument. Resolved an error about missing header files for uuid .

At 22% I the following error, which was discussed and solved here. . Short answer, built only uuid from util-linux.

Finally, I was able to build via Cmake for my MIPS-32 device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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