Build webrtc with headersfor c++ project.

930 views
Skip to first unread message

Peter Arnold

unread,
Apr 1, 2022, 7:33:51 PM4/1/22
to discuss-webrtc
Hi! I'm newbie to work with webrtc,  I need to use it for my diploma project. I build it, with an instructions described in here:

https://webrtc.googlesource.com/src/+/main/docs/native-code/development/index.md#webrtc-development

I have an libwebrtc.a file in out/Default/obj, but I need "include" header files for linking it with an application.
I found a repository of prebuilded webrtc pakcages, described below.
https://github.com/shiguredo-webrtc-build/webrtc-build/releases?page=9

So I found include and the library itself for building, maybe there is some way for building it with generation include header directories?

Also I found that as setup for compiler used libc++, I want to change it for stdlibc++, for gnu linux, I'm using ubuntu 20.04.

How should I configure gn for achieveing include direcory and correct compiler flags? I'm newbie for ninja also.

Mohammad Hefny

unread,
Apr 2, 2022, 11:19:57 AM4/2/22
to discuss...@googlegroups.com
Hi,

I hope my answer helps you in any way.

I took two approaches... first I added my code as an example in webrtc then compiled webrtc with example and voila I found my app compiled. And this was very useful to make my app works on arm32.
The other more straight forward approach is to link to libwebrtc.a
below is a makefile I use and works well for ubuntu 20.04

CXX=g++
EXE=de_webrtc
BIN=bin
BUILD = build
SRC = src
OBJS = $(BUILD)/main.o \
$(BUILD)/configFile.o \
$(BUILD)/udpClient.o \
$(BUILD)/webrtc_fakeAudioCaptureModule.o \
$(BUILD)/webrtc_source.o \
$(BUILD)/webrtc_videoSink.o \
$(BUILD)/webrtc_videoDevCapturer.o \
$(BUILD)/webrtc_capturerTrackSource.o \
$(BUILD)/webrtc_peerConnectionManager.o \
$(BUILD)/webrtc_userMedia.o \
$(BUILD)/webrtc_SetSessionDescriptionObserver.o \
$(BUILD)/webrtc_VideoEncoderFactory.o \
$(BUILD)/webrtc_plugin.o \
$(BUILD)/video_media_recorder.o \
$(BUILD)/getopt_cpp.o

SRCS = ../$(SRC)/main.cpp \
../$(SRC)/media_recorder/video_media_recorder.cpp \
../$(SRC)/configFile.cpp \
../$(SRC)/udpClient.cpp \
../$(SRC)/webrtc/webrtc_fakeAudioCaptureModule.cpp \
../$(SRC)/webrtc/webrtc_source.cpp \
../$(SRC)/webrtc/webrtc_videoSink.cpp \
../$(SRC)/webrtc/webrtc_userMedia.cpp \
../$(SRC)/webrtc/webrtc_videoDevCapturer.cpp \
../$(SRC)/webrtc/webrtc_capturerTrackSource.cpp \
../$(SRC)/webrtc/webrtc_peerConnectionManager.cpp \
../$(SRC)/webrtc/webrtc_SetSessionDescriptionObserver.cpp \
../$(SRC)/webrtc/webrtc_VideoEncoderFactory.cpp \
../$(SRC)/webrtc_plugin.cpp \
../$(SRC)/getopt_cpp.cpp \


INCLUDE= -I ../src/ -I ../lib/webrtc-local/third_party/ -I ../lib/webrtc94-local/third_party/abseil-cpp -I ../lib/webrtc94-local/include
LIBS = -lpthread -fexceptions -ljsoncpp -lwebrtc -ldl -lX11 -lexpat
LIBS_RELEASE = $(LIBS) -L ./lib/webrtc94-local/lib/x64/Release/
LIBS_DEBUG = $(LIBS) -L ./lib/webrtc94-local/lib/x64/Debug/
CXXFLAGS =
CXXFLAGS_RELEASE= $(CXXFLAGS) -DRELEASE -s -Werror=unused-variable -Werror=unused-result
CXXFLAGS_DEBUG= $(CXXFLAGS) -DDEBUG -g



release: webrtc.so.release
$(CXX) -o $(BIN)/$(EXE).so $(CXXFLAGS_RELEASE) $(OBJS) $(LIBS_RELEASE) ;
@echo "building finished ...";
@echo "DONE."

debug: webrtc.so.debug
$(CXX) -o $(BIN)/$(EXE).so $(CXXFLAGS_DEBUG) $(OBJS) $(LIBS_DEBUG) ;
@echo "building finished ...";
@echo "DONE."


copy: clean
mkdir -p $(BIN); \
cp config.*.json $(BIN);
cp ./src/media_recorder/scripts/script*.sh $(BIN);
@echo "copying finished ..."

clean:
rm -rf $(BIN) $(BUILD)



--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/404bebaf-fb2d-4193-a900-19ae2105013bn%40googlegroups.com.

Peter Arnold

unread,
Apr 2, 2022, 4:33:53 PM4/2/22
to discuss-webrtc
Thank you Mohammad! Thank you for the answering my question! But I have a little misunderstanding, 

SRCS = ../$(SRC)/main.cpp \
../$(SRC)/media_recorder/video_media_recorder.cpp \
../$(SRC)/configFile.cpp \
../$(SRC)/udpClient.cpp \
../$(SRC)/webrtc/webrtc_fakeAudioCaptureModule.cpp \
../$(SRC)/webrtc/webrtc_source.cpp \
../$(SRC)/webrtc/webrtc_videoSink.cpp \
../$(SRC)/webrtc/webrtc_userMedia.cpp \
../$(SRC)/webrtc/webrtc_videoDevCapturer.cpp \
../$(SRC)/webrtc/webrtc_capturerTrackSource.cpp \
../$(SRC)/webrtc/webrtc_peerConnectionManager.cpp \
../$(SRC)/webrtc/webrtc_SetSessionDescriptionObserver.cpp \
../$(SRC)/webrtc/webrtc_VideoEncoderFactory.cpp \
../$(SRC)/webrtc_plugin.cpp \
../$(SRC)/getopt_cpp.cpp \

Is it was your files, or I can find them in a project? I very interested to make some simple audio, video call application.
And where I can find an api-list and examples for c++, of using libwebrtc
Also, you alredy have linked your application with webrtc:
LIBS = -lpthread -fexceptions -ljsoncpp -lwebrtc -ldl -lX11 -lexpat

And which version of webrtc was used, for your qmake example? 
And please can you explain, how you add to examples your code and build it with ninja? 

Also , about approach with libwebrtc.a, is it possible to make some flags for crosscompilation, 
with ninja. for libwebrtc.a? If I want to use my toolchain?

суббота, 2 апреля 2022 г. в 18:19:57 UTC+3, mohamma...@gmail.com:

Mohammad Hefny

unread,
Apr 2, 2022, 5:22:07 PM4/2/22
to discuss...@googlegroups.com
Hi,

Yes these are my files.
but the important is the link flags
LIBS = -lpthread -fexceptions -ljsoncpp -lwebrtc -ldl -lX11 -lexpat

I used M94.

For ninja approach:

examples are in src/examples

I added my project as a folder

and updated the attached Build.gn by adding uavos project.

Thanks,
M. Hefny

BUILD.gn

Peter Arnold

unread,
Apr 2, 2022, 5:31:02 PM4/2/22
to discuss-webrtc
Thank you again Mohammad!
Mohammad, can you tell me, where I can find examples of using webrtc with c++, for video, and audio transmission?

And Also, I really Interested with first approach with building libwebrtc.a. But how can it possible, to group all includes with hierarchy for compiling and linking?
In first message, there was a source with wedrtc precompiled, and include directory, After my local building, there was no include directory with headers, is it possible to generate it, with building?


воскресенье, 3 апреля 2022 г. в 00:22:07 UTC+3, mohamma...@gmail.com:

Mohammad Hefny

unread,
Apr 2, 2022, 7:38:58 PM4/2/22
to discuss...@googlegroups.com
can you tell me, where I can find examples of using webrtc with c++, for video, and audio transmission?
I found no certain place. I just followed examples in webrtc code.

And Also, I really Interested with first approach with building libwebrtc.a. But how can it possible, to group all includes with hierarchy for compiling and linking?
you can collect all .h files in the code and point to them. that is it.

Thanks,
M. Hefny

Reply all
Reply to author
Forward
0 new messages