Undefined reference when building libmediasoupclient

When I build libmediasoupclient, it output errors as below:

[ 51%] Linking CXX executable test_mediasoupclient
CMakeFiles/test_mediasoupclient.dir/Device.test.cpp.o: In function __gthread_once(int*, void (*)())': Device.test.cpp:(.text+0x4c): undefined reference topthread_once’
CMakeFiles/test_mediasoupclient.dir/Device.test.cpp.o:(.data.rel.ro._ZTIN15mediasoupclient14PeerConnection32CreateSessionDescriptionObserverE[_ZTIN15mediasoupclient14PeerConnection32CreateSessionDescriptionObserverE]+0x10): undefined reference to `typeinfo for webrtc::CreateSessionDescriptionObserver’

It seems that I should add ‘-pthread’ to command, but I don’t know how to modify the make file.
My ubuntu is 18.04 and gcc is 7.4.0.

Which libwebrtc version are you linking against?

I use the m74 branch of libwebrtc, and I have fixed the errors by adding “pthread”, “{CMAKE_DL_LIBS}", "{X11_LIBRARIES}” to target_link_libraries in CMakeLists.txt:

target_link_libraries({PROJECT_NAME} PUBLIC sdptransform pthread {LIBWEBRTC_BINARY_PATH}/libwebrtc${CMAKE_STATIC_LIBRARY_SUFFIX}
{CMAKE_DL_LIBS} {X11_LIBRARIES}
)

Now, I try to build mediasoup-broadcaster-demo, it output errors as below:

CMake Error at CMakeLists.txt:18 (add_executable):
add_executable called with incorrect number of arguments

CMake Error at CMakeLists.txt:43 (target_sources):
Cannot specify sources for target “broadcaster” which is not built by this
project.

CMake Error at CMakeLists.txt:52 (target_include_directories):
Cannot specify include directories for target “broadcaster” which is not
built by this project.

Do you have any advice?

Which cmake version are you using?

cmake version is 3.10.2

And building libwebrtc command is:
gn gen out/m74 --args=‘is_debug=false is_component_build=false is_clang=true rtc_include_tests=false rtc_use_h264=true rtc_enable_protobuf=false use_rtti=true use_custom_libcxx=false’

CmakeLists.txt needs to be refactored since it does only work for new cmake versions.

Related issue: https://github.com/versatica/mediasoup-broadcaster-demo/issues/2

It works with cmake 3.14.4. Thank you!