vsimon / webrtcbuilds

Getting started with WebRTC natively is no easy picnic. The goal of webrtcbuilds is to provide a single standalone WebRTC static library and package.
BSD 3-Clause "New" or "Revised" License
202 stars 164 forks source link

PeerConnection client wiki post does not behave correctly. Cannot compile #71

Open EliSchleifer opened 6 years ago

EliSchleifer commented 6 years ago

The basic instructions for building the WebRTC PeerConnection client on Linux no longer appears to work.

I did try to assemble a Makefile version. But that ends up failing with a couple unresolved symbols.

INC=-I/ -I../../.. -I/usr/include/jsoncpp -I../../../third_party/libyuv/include WEBRTCBUILDS_FOLDER=/home/elischleifer/WebRTCBuilds/webrtcbuilds/out/webrtcbuilds-20416-9de3aac-linux-x64 PKG_CONFIG_PATH=$WEBRTCBUILDS_FOLDER/lib/Debug/pkgconfig CPPFLAGS=-DWEBRTC_POSIX

client: linux/main.cc linux/main_wnd.cc conductor.cc defaults.cc peer_connection_client.cc @echo Building client
g++ $(INC) $(CPPFLAGS) -o $@ $^ \ $(shell pkg-config --cflags --libs --define-variable=prefix=$(WEBRTCBUILDS_FOLDER) libwebrtc_full) \ $(shell pkg-config --cflags --libs gtk+-2.0) \ $(shell pkg-config --cflags --libs x11)

clean: rm -f client client.o

vsimon commented 6 years ago

Hi! Thanks for this, I will take a look and see what things need updating.

vsimon commented 6 years ago

I found an issue with certain objects related to 'tools' in the name not being added, but I don't believe that would affect this since the PeerConnection client doesn't include anything from 'rtc_tools' (only the server does).

But one other thing I was reminded of was that this builds with rtti off by default, that could affect this. Could you try putting -fno-rtti in the g++ line or CPPFLAGS to see if that helps?

sampathkumar81293 commented 6 years ago

Hi @EliSchleifer Are you able to fix your issue ? I have tried the same building peerconnection using webrtcbuilds projects.I have followed the instructions mentioned in the wiki but ended up with few unresolved errors

In function Conductor::OnIceCandidate(webrtc::IceCandidateInterface const*): conductor.cc:(.text+0x182a): undefined reference to Json::Value::operator=(Json::Value)

qiaotian commented 6 years ago

Hi @vsimon When I execute g++ -o peerconnection_client linux/main.cc linux/main_wnd.cc conductor.cc defaults.cc peer_connection_client.cc -I/home/qiao/webrtcbuilds/out/src/third_party/jsoncpp/source/include/ -I/home/qiao/webrtcbuilds/out/src/third_party/libyuv/include/ $(pkg-config --cflags --libs --define-variable=prefix=$WEBRTCBUILDS_FOLDER libwebrtc_full) $(pkg-config --cflags --libs gtk+-2.0) $(pkg-config --cflags --libs x11)

after I enter the peerconnection client example directory, serveral lines of error are received as follows:

/tmp/ccFgllrd.o:(.rodata._ZTI18CustomSocketServer[_ZTI18CustomSocketServer]+0x10): undefined reference totypeinfo for rtc::PhysicalSocketServer' /tmp/ccTsaX9m.o: In function Conductor::OnIceCandidate(webrtc::IceCandidateInterface const*)': conductor.cc:(.text+0x1731): undefined reference toJson::StyledWriter::StyledWriter()' conductor.cc:(.text+0x1745): undefined reference to Json::Value::Value(Json::ValueType)' conductor.cc:(.text+0x1785): undefined reference toJson::Value::Value(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' conductor.cc:(.text+0x1799): undefined reference to Json::Value::operator[](char const*)' conductor.cc:(.text+0x17ae): undefined reference toJson::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x17bd): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x17fc): undefined reference toJson::Value::Value(int)' conductor.cc:(.text+0x1810): undefined reference to Json::Value::operator[](char const*)' conductor.cc:(.text+0x1825): undefined reference toJson::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x1834): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x194a): undefined reference toJson::Value::Value(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' conductor.cc:(.text+0x195e): undefined reference to Json::Value::operator[](char const*)' conductor.cc:(.text+0x1973): undefined reference toJson::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x1982): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x19a2): undefined reference toJson::StyledWriter::write[abi:cxx11](Json::Value const&)' conductor.cc:(.text+0x19ff): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x1a8a): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x1ab2): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x1ae8): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x1b24): undefined reference to Json::Value::~Value()' /tmp/ccTsaX9m.o: In functionConductor::OnMessageFromPeer(int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)': conductor.cc:(.text+0x27c7): undefined reference to Json::Reader::Reader()' conductor.cc:(.text+0x27db): undefined reference toJson::Value::Value(Json::ValueType)' conductor.cc:(.text+0x27fd): undefined reference to `Json::Reader::parse(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, Json::Value&, bool)' conductor.cc:(.text+0x2943): undefined reference to rtc::GetStringFromJsonObject(Json::Value const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' conductor.cc:(.text+0x2ae3): undefined reference tortc::GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >)' conductor.cc:(.text+0x2f3c): undefined reference to `rtc::GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >)' conductor.cc:(.text+0x2f9d): undefined reference to rtc::GetIntFromJsonObject(Json::Value const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int*)' conductor.cc:(.text+0x2ffa): undefined reference tortc::GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >)' conductor.cc:(.text+0x34d3): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x389e): undefined reference toJson::Value::~Value()' /tmp/ccTsaX9m.o: In function `Conductor::OnSuccess(webrtc::SessionDescriptionInterface)': conductor.cc:(.text+0x544c): undefined reference to Json::StyledWriter::StyledWriter()' conductor.cc:(.text+0x5460): undefined reference toJson::Value::Value(Json::ValueType)' conductor.cc:(.text+0x54a0): undefined reference to Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' conductor.cc:(.text+0x54b4): undefined reference toJson::Value::operator[](char const)' conductor.cc:(.text+0x54c9): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x54d8): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x5500): undefined reference to Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' conductor.cc:(.text+0x5514): undefined reference toJson::Value::operator[](char const)' conductor.cc:(.text+0x5529): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x5538): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x5558): undefined reference to Json::StyledWriter::write[abi:cxx11](Json::Value const&)' conductor.cc:(.text+0x558f): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x5608): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x5630): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x5658): undefined reference to Json::Value::~Value()' /tmp/ccTsaX9m.o: In functionJson::StyledWriter::~StyledWriter()': conductor.cc:(.text._ZN4Json12StyledWriterD2Ev[_ZN4Json12StyledWriterD5Ev]+0xd): undefined reference to vtable for Json::StyledWriter' conductor.cc:(.text._ZN4Json12StyledWriterD2Ev[_ZN4Json12StyledWriterD5Ev]+0x50): undefined reference toJson::Writer::~Writer()' /tmp/cc3OxrlM.o:(.rodata._ZTI20PeerConnectionClient[_ZTI20PeerConnectionClient]+0x28): undefined reference to typeinfo for rtc::MessageHandler' collect2: error: ld returned 1 exit status

Could you please help me figure out what's wrong?

agouaillard commented 6 years ago

you are missing two libraries that are are defined as "source_set" in GN and thus not included in libwebrtc:

JSON (in third_party) and rtc_json.

you need to either:

  1. change in the corresponding bUILDgn file "source_set" in "etc_static_lib" and rebuild to get the libraries
  2. build the libraries yourself
  3. locate the .o (or obj) files and add them to your project.

On Mon, Feb 26, 2018 at 1:19 PM, T QIAO notifications@github.com wrote:

Hi @vsimon https://github.com/vsimon When I execute g++ -o peerconnection_client linux/main.cc linux/main_wnd.cc conductor.cc defaults.cc peer_connection_client.cc -I/home/qiao/webrtcbuilds/out/ src/third_party/jsoncpp/source/include/ -I/home/qiao/webrtcbuilds/out/ src/third_party/libyuv/include/ $(pkg-config --cflags --libs --define-variable=prefix=$WEBRTCBUILDS_FOLDER libwebrtc_full) $(pkg-config --cflags --libs gtk+-2.0) $(pkg-config --cflags --libs x11)

after I enter the peerconnection client example directory, serveral lines of error are received as follows:

/tmp/ccFgllrd.o:(.rodata.ZTI18CustomSocketServer[ ZTI18CustomSocketServer]+0x10): undefined reference totypeinfo for rtc::PhysicalSocketServer' /tmp/ccTsaX9m.o: In function Conductor::OnIceCandidate(webrtc::IceCandidateInterface const)': conductor.cc:(.text+0x1731): undefined reference to Json::StyledWriter::StyledWriter()' conductor.cc:(.text+0x1745): undefined reference to Json::Value::Value(Json::ValueType)' conductor.cc:(.text+0x1785): undefined reference toJson::Value::Value(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' conductor.cc:(.text+0x1799): undefined reference to Json::Value::operator[](char const)' conductor.cc:(.text+0x17ae): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x17bd): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x17fc): undefined reference to Json::Value::Value(int)' conductor.cc:(.text+0x1810): undefined reference to Json::Value::operator' conductor.cc:(.text+0x1825): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x1834): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x194a): undefined reference to Json::Value::Value(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' conductor.cc:(.text+0x195e): undefined reference to Json::Value::operator' conductor.cc:(.text+0x1973): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x1982): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x19a2): undefined reference to Json::StyledWriter::write[abi:cxx11](Json::Value const&)' conductor.cc:(.text+0x19ff): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x1a8a): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x1ab2): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x1ae8): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x1b24): undefined reference to Json::Value::~Value()' /tmp/ccTsaX9m.o: In functionConductor::OnMessageFromPeer(int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)': conductor.cc:(.text+0x27c7): undefined reference to Json::Reader::Reader()' conductor.cc:(.text+0x27db): undefined reference to Json::Value::Value(Json::ValueType)' conductor.cc:(.text+0x27fd): undefined reference to Json::Reader::parse(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, Json::Value&, bool)' conductor.cc:(.text+0x2943): undefined reference tortc:: GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > *)' conductor.cc:(.text+0x2ae3): undefined reference to rtc::GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >*)' conductor.cc:(.text+0x2f3c): undefined reference tortc::GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >*)' conductor.cc:(.text+0x2f9d): undefined reference to rtc::GetIntFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' conductor.cc:(.text+0x2ffa): undefined reference tortc:: GetStringFromJsonObject(Json::Value const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >)' conductor.cc:(.text+0x34d3): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x389e): undefined reference toJson::Value::~Value()' /tmp/ccTsaX9m.o: In function Conductor::OnSuccess(webrtc:: SessionDescriptionInterface)': conductor.cc:(.text+0x544c): undefined reference toJson::StyledWriter::StyledWriter()' conductor.cc:(.text+0x5460): undefined reference to Json::Value::Value(Json::ValueType)' conductor.cc:(.text+0x54a0): undefined reference toJson::Value::Value(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' conductor.cc:(.text+0x54b4): undefined reference to Json::Value::operator[](char const)' conductor.cc:(.text+0x54c9): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x54d8): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x5500): undefined reference to Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' conductor.cc:(.text+0x5514): undefined reference to Json::Value::operator' conductor.cc:(.text+0x5529): undefined reference to Json::Value::operator=(Json::Value const&)' conductor.cc:(.text+0x5538): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x5558): undefined reference to Json::StyledWriter::write[abi:cxx11](Json::Value const&)' conductor.cc:(.text+0x558f): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x5608): undefined reference toJson::Value::~Value()' conductor.cc:(.text+0x5630): undefined reference to Json::Value::~Value()' conductor.cc:(.text+0x5658): undefined reference toJson::Value::~Value()' /tmp/ccTsaX9m.o: In function Json::StyledWriter::~StyledWriter()': conductor.cc:(.text.ZN4Json12StyledWriterD2Ev[ ZN4Json12StyledWriterD5Ev]+0xd): undefined reference tovtable for Json::StyledWriter' conductor.cc:(.text.ZN4Json12StyledWriterD2Ev[ ZN4Json12StyledWriterD5Ev]+0x50): undefined reference to Json::Writer::~Writer()' /tmp/cc3OxrlM.o:(.rodata.ZTI20PeerConnectionClient[ ZTI20PeerConnectionClient]+0x28): undefined reference totypeinfo for rtc::MessageHandler' collect2: error: ld returned 1 exit status`

Could you please help me figure out what's wrong?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vsimon/webrtcbuilds/issues/71#issuecomment-368401909, or mute the thread https://github.com/notifications/unsubscribe-auth/AAT1nrxLIvydWf5rQgarNh57luQ6Tz-Wks5tYk0HgaJpZM4QIW4E .

-- Alex. Gouaillard, PhD, PhD, MBA

President - CoSMo Software Consulting, Singapore

sg.linkedin.com/agouaillard

-

qiaotian commented 6 years ago

@agouaillard Thanks a lot for your solution. As I'm new to webrtc, I don't get the exact meaning of "etc_static_lib" and where it is. Moreover, I didn't change any BUILD.gn file in webrtc source folder. Why 'rtc_json.a' failed to be generated while libjsoncpp.a succeed?

agouaillard commented 6 years ago

first, i'm not vsimon.

then, this is the way it is in the original code. To reduce the overall build time, GN defines some "source_set" target instead of the usual library targets (static_lin, shared_lib). When used, corresponding Libraries are not created, and the corresponding collection of .o or .obj files are directly added to targets that require them. That allows to avoid the linking time of intermediate libraries.

Since libwebrtc GN target does not depend on jsoncpp nor on rtc_json, those two source sets (and corresponding symbols) are not included in the final libwebrtc library. The reason the peerconnection examples compiles when you compile the source code is because the peerconnection GN target depend son rtc_json and jsoncpp and include the compiled objects at compilation time. When you try to reproduce it with a pre-compiled libwebrtc, it just does not work.

Finally, one way to make it work for you is to modify the GN files or do one of the three things I listed before.

good luck.

On Mon, Feb 26, 2018 at 2:40 PM, T QIAO notifications@github.com wrote:

@vsimon https://github.com/vsimon Thanks a lot for your solution. As I'm familiar with webrtc, I doesn't get the exact meaning of "etc_static_lib" and where it is. Moreover, I didn't change any BUILD.gn file in webrtc source folder. Why 'rtc_json.a' failed to be generated meanwhile libjsoncpp.a succeed?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vsimon/webrtcbuilds/issues/71#issuecomment-368414801, or mute the thread https://github.com/notifications/unsubscribe-auth/AAT1npdPy7zm4IZNupog9nQzMmKLaXzUks5tYmAIgaJpZM4QIW4E .

-- Alex. Gouaillard, PhD, PhD, MBA

President - CoSMo Software Consulting, Singapore

sg.linkedin.com/agouaillard

-

qiaotian commented 6 years ago

@agouaillard I'm extraordinarily grateful for your feedback, and terriblly sorry for my muddlehead. It seems to work now. Best wishes!