cmake . -Bbuild -DLIBWEBRTC_INCLUDE_PATH:PATH="/home/yq/share/src/mediasoup/client/libwebrtc/src" -DLIBWEBRTC_BINARY_PATH:PATH="/home/yq/share/src/mediasoup/client/libwebrtc/src/out/mybuild-m79/obj" -DOPENSSL_INCLUDE_DIR:PATH="/usr/local/include" -DCMAKE_USE_OPENSSL=ON -DMEDIASOUPCLIENT_LOG_DEV=true -DMEDIASOUPCLIENT_LOG_TRACE=true
编译注意事项:
cpr 里边有个libcurl.so 需要依赖openssl 相关的库, libwebrtc.a 也有同样的依赖, 所以在编译libcurl.so 时依赖的openssl 相关的库和头文件必须是 libwebrtc.a 所依赖的头文件和库;
依赖的库有 libssl.a libcrypto.a;
路径为:
openssl 头文件路径为:
src/build/linux/debian_sid_amd64-sysroot/usr/include/openssl
另外需要注意的是x86_64平台的相关配置需要copy到openssl头文件里边:
cp src/build/linux/debian_sid_amd64-sysroot/usr/include/x86_64-linux-gnu/openssl/*
src/build/linux/debian_sid_amd64-sysroot/usr/include/openssl
以上的cmake 选项只指定了头文件路径, 没有指定库的路径, 所以需要把webrtc中的相关库复制到系统路径:
cd webrtc:
sudo cp ./src/build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu/libssl.a /usr/local/lib/
sudo cp ./src/build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu/libcrypto.a /usr/local/lib/
sudo rm /usr/local/include/openssl -r
sudo cp ./src/build/linux/debian_sid_amd64-sysroot/usr/include/openssl /usr/local/include/openssl -r
把x86_64 openssl 的配置头文件copy过去:
sudo cp ./src/build/linux/debian_sid_amd64-sysroot/usr/include/x86_64-linux-gnu/openssl/* /usr/local/include/openssl/
make -C build
问题:
[ 0%] Linking C shared library ../../../../lib/libcurl.so
/usr/bin/ld: /usr/local/lib/libssl.a(s3_clnt.o): relocation R_X86_64_PC32 against symbol `ssl3_get_server_hello' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: 错误的值
解决:
需要把/usr/local/lib/libssl.a 替换为webrtc 目录下的libssl.a
所在目录: src/build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu/libssl.a
问题:
/home/yq/share/src/mediasoup/demo/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:55:25: error: ‘uint8_t’ was not declared in this scope
解决:
https://stackoverflow.com/questions/1971062/error-uint8-t-has-not-been-declared
问题:
/home/yq/share/src/mediasoup/demo/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/ortc.cpp: In function ‘void mediasoupclient::ortc::validateRtpCodecCapability(json&)’:
/home/yq/share/src/mediasoup/demo/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/ortc.cpp:106:81: error: use of deleted function ‘bool std::regex_match(const std::__cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, std::__cxx11::match_results
std::regex_match(mimeTypeIt->get(), mimeTypeMatch, MimeTypeRegex);
^
In file included from /usr/include/c++/7/regex:62:0,
from /home/yq/share/src/mediasoup/demo/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/ortc.cpp:8:
/usr/include/c++/7/bits/regex.h:2121:5: note: declared here
regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&,
解决:
https://stackoverflow.com/questions/32164501/error-use-of-deleted-function-bool-regex-match-with-gcc-5-2-0
问题:
[ 77%] Linking CXX executable broadcaster
/usr/bin/ld: broadcaster: hidden symbol `SSLeay' in /home/yq/share/src/mediasoup/client/libwebrtc/src/out/mybuild-m79/obj/libwebrtc.a(crypto.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
原因:
SSLeay 在特定的ssl 版本中才有的函数, 经过对比发现, openssl 头文件和库的版本不一致;
解决:
该工程所依赖的openssl 的头文件和库文件都需要依赖 webrtc 项目中的 openssl项目; 具体依赖的库为 libcrypto.a libssl.a; 头文件也在webrtc 里边有相关路径; 里边有32位版本和64位版本, 需要用到与编译系统一样的版本即可!