交叉编译 aws webrtc 库失败
failed cross compiling aws webrtc library
我正在尝试为 arm 交叉编译 aws webrtc 库(https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c)。所以我按照 Readme.md 上的说明进行操作,但我失败了。
我做了什么
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
我遇到的错误
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)
您的 ARM 工具链或构建系统使用它的方式有问题。你从哪里得到它,你是如何安装它的?
header sys/capability.h
包含在 ARM 工具链中。例如,当我安装 Debian 软件包 gcc-arm-linux-gnueabihf
时,这个 header 文件被复制到 /usr/arm-linux-gnueabihf/include/linux/capability.h
。工具链应该可以自行找到它。
命令 arm-linux-gnueabihf-gcc -v
将向您显示工具链配置为查找自己的 header 文件的位置。例如。在下面的输出中,重要的是 --includedir=/usr/arm-linux-gnueabihf/include
,应该相对于此目录找到 header。我为超长的线路道歉。
$ 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)
您还可以尝试增加 cmake 构建过程的详细程度,以验证它是否调用了正确的交叉编译器。我忘记了细节,但也许添加一个标志 -v
会有所帮助。
我正在尝试为 arm 交叉编译 aws webrtc 库(https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c)。所以我按照 Readme.md 上的说明进行操作,但我失败了。
我做了什么
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
我遇到的错误
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)
您的 ARM 工具链或构建系统使用它的方式有问题。你从哪里得到它,你是如何安装它的?
header sys/capability.h
包含在 ARM 工具链中。例如,当我安装 Debian 软件包 gcc-arm-linux-gnueabihf
时,这个 header 文件被复制到 /usr/arm-linux-gnueabihf/include/linux/capability.h
。工具链应该可以自行找到它。
命令 arm-linux-gnueabihf-gcc -v
将向您显示工具链配置为查找自己的 header 文件的位置。例如。在下面的输出中,重要的是 --includedir=/usr/arm-linux-gnueabihf/include
,应该相对于此目录找到 header。我为超长的线路道歉。
$ 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)
您还可以尝试增加 cmake 构建过程的详细程度,以验证它是否调用了正确的交叉编译器。我忘记了细节,但也许添加一个标志 -v
会有所帮助。