Skip to content
Advertisement

How to add webrtc native apis into my qt project?

I have been in trouble for a few days, so I really need some exports of webrtc to help me.

I compiled successfully with the source code by ninja, and I can run the peerconnection example. I add the static libraries(.a file) into my qt project one by one, and then I set the include path to the source code dir. It compiles successfully when I call createpeerconnectionfactory. However, when I’m trying to new a PeerConnectionInterface::RTCConfiguration object, the error occurs:

linux/webrtc/src/api/array_view.h:156: error: undefined reference to rtc::FatalMessage::FatalMessage(char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' linux/webrtc/src/api/array_view.h:158: error: more undefined references tortc::FatalMessage::FatalMessage(char const*, int, std::__cxx11::basic_string, std::allocator >*)’ follow

I searched the head files, and find the function is declared in rtc_base/checks.h I go to read the BUILD.GN and found the “checks” has been build into librtc_base_genetic.a. I’m pretty sure I have add this library into my qt .pro file.

I’m working with ubuntu18, QT5.10.1, and I’ve got the source code in may 19th. I’d be so grateful if you can give me any suggestion, maybe how this occurs or how can I solve this problem.

Is there any one who has imported the webrtc native libraries and has used the apis successfully? I really need someone’s help to get over this tough beginning. My most grateful!

Advertisement

Answer

It’s probably because of the ABI incompatibility of the std::string. The libstdc++ has changed from old COW implementation to another one. The linker wants the __cxx11 version of the std::string, but the library is compiled with another one.

A possible solution is to use the libstdc++ from actual OS instead of libc++ that comes with the WebRTC Native. To do that, edit all the command line options in the ninja files to remove things like -nostdlib and set the sysroot to actual root:

sed -i -re 's#obj/buildtools/third_party/libc[^[:space:]]*s*##g' obj/webrtc.ninja
find . -type f -name *.ninja -a ! -name *libc++* -exec sed -i -re 's/s*-nostd(inc|lib)++//' {} +
find . -type f -name *.ninja -a ! -name *libc++* -exec sed -i -re 's/s*S*isystemS*libc++S*//g' {} +
find . -type f -name *.ninja -exec sed -i -re 's#(--sysroot=)[^[:space:]]*#1/#' {} +
find . -type f -name *.ninja -exec sed -i -re 's#(-L)[^[:space:]]*-sysroot#1#g' {} +
find . -type f -name *.ninja -exec sed -i -re 's#(rpath-link=)[^[:space:]]*-sysroot#1#g' {} +

There are other problems, and they change as their code changes. It’s a lot of work to build and use that library.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement