I'm trying to cross compile aws webrtc library(https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c) for arm. So I followed the instruction on Readme.md but I failed.
What I did
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
cmake .. -DBUILD_TEST=TRUE -DBUILD_OPENSSL=TRUE -DBUILD_STATIC_LIBS=TRUE -DBUILD_OPENSSL_PLATFORM=linux-generic32 -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-pc-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-unknown-linux-uclibcgnueabi
The error I encountered
Scanning dependencies of target kvsCommonLws
[ 26%] Building C object CMakeFiles/kvsCommonLws.dir/src/source/Common/Auth.c.o
In file included from /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libkvsCommonLws/build/src/libkvsCommonLws-download/src/source/Common/Include_i.h:41,
from /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libkvsCommonLws/build/src/libkvsCommonLws-download/src/source/Common/Auth.c:5:
/home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/include/libwebsockets.h:120:10: fatal error: sys/capability.h: No such file or directory
120 | #include <sys/capability.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/kvsCommonLws.dir/build.make:62: recipe for target 'CMakeFiles/kvsCommonLws.dir/src/source/Common/Auth.c.o' failed
make[5]: *** [CMakeFiles/kvsCommonLws.dir/src/source/Common/Auth.c.o] Error 1
make[4]: *** [CMakeFiles/kvsCommonLws.dir/all] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/kvsCommonLws.dir/all' failed
Makefile:129: recipe for target 'all' failed
CMakeFiles/libkvsCommonLws-download.dir/build.make:111: recipe for target 'build/src/libkvsCommonLws-download-stamp/libkvsCommonLws-download-build' failed
make[3]: *** [all] Error 2
make[2]: *** [build/src/libkvsCommonLws-download-stamp/libkvsCommonLws-download-build] Error 2
make[1]: *** [CMakeFiles/libkvsCommonLws-download.dir/all] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/libkvsCommonLws-download.dir/all' failed
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
CMake Error at CMake/Utilities.cmake:65 (message):
CMake step for libkvsCommonLws failed: 2
Call Stack (most recent call first):
CMakeLists.txt:150 (build_dependency)
Something is wrong with your ARM toolchain or how the build system uses it. Where did you get it from and how did you install it?
The header sys/capability.h
is included with the ARM toolchain. For example, when I install the Debian package gcc-arm-linux-gnueabihf
then this header file gets copied to /usr/arm-linux-gnueabihf/include/linux/capability.h
. The toolchain is supposed to find it there on its own.
The command arm-linux-gnueabihf-gcc -v
will show you where the toolchain is configured to look for its own header files. E.g. in output below it's --includedir=/usr/arm-linux-gnueabihf/include
that matters, the header should be found relative to this directory. I apologize for the super long line.
$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/10/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-1' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20201207 (Debian 10.2.1-1)
You can also try increasing the verbosity of your cmake build process to verify that it's calling the right cross compiler. I've forgotten the details, but perhaps adding a flag -v
will help.