Build errors in Ubuntu 18.04 for libmediasoupclient and mediasoup-boradcaster-demo

Having problems compiling both mediasoup-broadcaster-demo and libmediasoupclient on my Linux box:

Ubuntu 18.04
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
cmake version 3.14.4

I have installed webrtc at m84 as per the instructions here: https://mediasoup.org/documentation/v3/libmediasoupclient/installation.

Here the build errors for libmediasoupclient:

/usr/include/c++/7/bits/basic_string.h:6507:3: note: ‘std::__cxx11::stod’
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp: At global scope:
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:18:14: error: ‘string’ in namespace ‘webrtc::webrtc::std’ does not name a type
const std::string& id,
^~~~~~
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:19:14: error: ‘string’ in namespace ‘webrtc::webrtc::std’ does not name a type
const std::string& localId,
^~~~~~
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:20:14: error: ‘string’ in namespace ‘webrtc::webrtc::std’ does not name a type
const std::string& producerId,
^~~~~~
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp: In constructor ‘webrtc::webrtc::mediasoupclient::Consumer::Consumer(webrtc::webrtc::mediasoupclient::Consumer::PrivateListener*, webrtc::webrtc::mediasoupclient::Consumer::Listener*, const int&, const int&, const int&, webrtc::webrtc::webrtc::MediaStreamTrackInterface*, const json&, const json&)’:
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:24:59: error: class ‘webrtc::webrtc::mediasoupclient::Consumer’ does not have any field named ‘id’
: privateListener(privateListener), listener(listener), id(id), localId(localId),
^~
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:24:67: error: class ‘webrtc::webrtc::mediasoupclient::Consumer’ does not have any field named ‘localId’
: privateListener(privateListener), listener(listener), id(id), localId(localId),
^~~~~~~
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:25:5: error: class ‘webrtc::webrtc::mediasoupclient::Consumer’ does not have any field named ‘producerId’
producerId(producerId), track(track), rtpParameters(rtpParameters), appData(appData)
^~~~~~~~~~
In file included from /home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:7:0:
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp: In member function ‘void webrtc::webrtc::mediasoupclient::Consumer::Resume()’:
/home/sumitj/bodyline/third_party/libmediasoupclient/include/Logger.hpp:164:29: error: ‘snprintf’ is not a member of ‘webrtc::webrtc::std’
int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, “[ERROR]” _MSC_LOG_STR_DESC desc, _MSC_LOG_ARG, ## VA_ARGS );
^
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:82:3: note: in expansion of macro ‘MSC_ERROR’
MSC_ERROR(“consumer closed”);
^~~~~~~~~
/home/sumitj/bodyline/third_party/libmediasoupclient/include/Logger.hpp:164:29: note: suggested alternatives:
int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, “[ERROR]” _MSC_LOG_STR_DESC desc, _MSC_LOG_ARG, ## VA_ARGS );
^
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:82:3: note: in expansion of macro ‘MSC_ERROR’
MSC_ERROR(“consumer closed”);
^~~~~~~~~
In file included from /usr/include/c++/7/cstdio:42:0,
from /usr/include/c++/7/ext/string_conversions.h:43,
from /usr/include/c++/7/bits/basic_string.h:6361,
from /usr/include/c++/7/string:52,
from /home/sumitj/bodyline/third_party/libmediasoupclient/include/Exception.hpp:5,
from /home/sumitj/bodyline/third_party/libmediasoupclient/include/Consumer.hpp:4,
from /home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:4:
/usr/include/stdio.h:340:12: note: ‘snprintf’
extern int snprintf (char *__restrict __s, size_t __maxlen,
^~~~~~~~
/usr/include/stdio.h:340:12: note: ‘snprintf’
/usr/include/stdio.h:340:12: note: ‘snprintf’
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp: At global scope:
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:89:1: error: expected ‘}’ at end of input
} // namespace mediasoupclient
^
/home/sumitj/bodyline/third_party/libmediasoupclient/src/Consumer.cpp:89:1: error: expected ‘}’ at end of input
CMakeFiles/mediasoupclient.dir/build.make:62: recipe for target ‘CMakeFiles/mediasoupclient.dir/src/Consumer.cpp.o’ failed
make[2]: *** [CMakeFiles/mediasoupclient.dir/src/Consumer.cpp.o] Error 1
make[2]: Leaving directory ‘/home/sumitj/bodyline/third_party/libmediasoupclient/build’
CMakeFiles/Makefile2:72: recipe for target ‘CMakeFiles/mediasoupclient.dir/all’ failed
make[1]: *** [CMakeFiles/mediasoupclient.dir/all] Error 2
make[1]: Leaving directory ‘/home/sumitj/bodyline/third_party/libmediasoupclient/build’
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
make: Leaving directory ‘/home/sumitj/bodyline/third_party/libmediasoupclient/build’

=========== libmediasoupclient Build Configuration =============

– MEDIASOUPCLIENT_BUILD_TESTS = OFF
– MEDIASOUPCLIENT_LOG_TRACE = OFF
– MEDIASOUPCLIENT_LOG_DEV = OFF
– LIBWEBRTC_INCLUDE_PATH = /home/sumitj/webrtc-checkout-m84/src
– LIBWEBRTC_BINARY_PATH = /home/sumitj/webrtc-checkout-m84/src/out/m84/obj

Build errors for mediasoup-broadcaster-demo:
make: Entering directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
make[1]: Entering directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
make[2]: Entering directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
make[2]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
make[2]: Entering directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
[ 0%] Building CXX object libwebrtc/CMakeFiles/webrtc_broadcaster.dir/test/testsupport/ios_file_utils.mm.o
c++: error trying to exec ‘cc1objplus’: execvp: No such file or directory
libwebrtc/CMakeFiles/webrtc_broadcaster.dir/build.make:205: recipe for target ‘libwebrtc/CMakeFiles/webrtc_broadcaster.dir/test/testsupport/ios_file_utils.mm.o’ failed
make[2]: *** [libwebrtc/CMakeFiles/webrtc_broadcaster.dir/test/testsupport/ios_file_utils.mm.o] Error 1
make[2]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
CMakeFiles/Makefile2:1657: recipe for target ‘libwebrtc/CMakeFiles/webrtc_broadcaster.dir/all’ failed
make[1]: *** [libwebrtc/CMakeFiles/webrtc_broadcaster.dir/all] Error 2
make[1]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
make: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’

I filed bugs (libmediasoupclient/issues/89 and mediasoup-broadcaster-demo/issues/11) but they were closed off saying that I should try to use cmake 14.4 which I was already using. There was also a suggestion of trying with “use_custom_libcxx=false” which I was already doing as per the documentation.

Any ideas on what am I missing here?

The .mm are Objective-C++ files (typical for iOS).

To try to get further with building the mediasoup-broadcaster-demo, just comment out/remove these two lines in /deps/libwebrtc/CMakeLists.txt:
test/testsupport/ios_file_utils.mm
test/testsupport/mac_file_utils.mm

OR, install cc1objplus, as per error:

Alright progressed a little further but still failing:

[ 77%] Building CXX object libmediasoupclient/CMakeFiles/mediasoupclient.dir/src/Logger.cpp.o
In file included from /home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:3:0:
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:55:3: warning: elaborated-type-specifier for a scoped enum must not use the ‘class’ keyword
enum class LogLevel : uint8_t
^~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:55:14: error: use of enum ‘LogLevel’ without previous declaration
enum class LogLevel : uint8_t
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:55:25: error: ‘uint8_t’ was not declared in this scope
enum class LogLevel : uint8_t
^~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:55:25: note: suggested alternative: ‘u_int8_t’
enum class LogLevel : uint8_t
^~~~~~~
u_int8_t
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:55:25: error: expected ‘;’ at end of member declaration
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:56:3: error: expected unqualified-id before ‘{’ token
{
^
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:67:23: error: ‘LogLevel’ has not been declared
virtual void OnLog(LogLevel level, char* payload, size_t len) = 0;
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:72:15: error: ‘LogLevel’ has not been declared
void OnLog(LogLevel level, char* payload, size_t len) override;
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:75:27: error: ‘LogLevel’ has not been declared
static void SetLogLevel(LogLevel level);
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/include/Logger.hpp:80:10: error: ‘LogLevel’ does not name a type; did you mean ‘Logger’?
static LogLevel logLevel;
^~~~~~~~
Logger
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:12:10: error: ‘LogLevel’ in ‘class mediasoupclient::Logger’ does not name a type
Logger::LogLevel Logger::logLevel = Logger::LogLevel::LOG_NONE;
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:16:35: error: variable or field ‘SetLogLevel’ declared void
void Logger::SetLogLevel(Logger::LogLevel level)
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:16:35: error: ‘LogLevel’ is not a member of ‘mediasoupclient::Logger’
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:33:40: error: variable or field ‘OnLog’ declared void
void Logger::DefaultLogHandler::OnLog(LogLevel /level/, char* payload, size_t /len/)
^~~~~~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:33:40: error: ‘LogLevel’ was not declared in this scope
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:33:40: note: suggested alternative: ‘Logger’
void Logger::DefaultLogHandler::OnLog(LogLevel /level/, char* payload, size_t /len/)
^~~~~~~~
Logger
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:33:60: error: expected primary-expression before ‘char’
void Logger::DefaultLogHandler::OnLog(LogLevel /level/, char* payload, size_t /len/)
^~~~
/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/deps/libmediasoupclient/src/Logger.cpp:33:89: error: expected primary-expression before ‘)’ token
void Logger::DefaultLogHandler::OnLog(LogLevel /level/, char* payload, size_t /len/)
^
libmediasoupclient/CMakeFiles/mediasoupclient.dir/build.make:101: recipe for target ‘libmediasoupclient/CMakeFiles/mediasoupclient.dir/src/Logger.cpp.o’ failed
make[2]: *** [libmediasoupclient/CMakeFiles/mediasoupclient.dir/src/Logger.cpp.o] Error 1
make[2]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
CMakeFiles/Makefile2:1432: recipe for target ‘libmediasoupclient/CMakeFiles/mediasoupclient.dir/all’ failed
make[1]: *** [libmediasoupclient/CMakeFiles/mediasoupclient.dir/all] Error 2
make[1]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
make: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’

Change from enum class LogLevel : uint8_t to enum class LogLevel : u_int8_t

Then try again.

Ok, so now finally getting a linker error:

[ 81%] Linking CXX executable broadcaster
/usr/bin/ld: /home/sumitj/webrtc-checkout-m84/src/out/m84/obj/libwebrtc.a(latebindingsymboltable_linux.o): undefined reference to symbol ‘dlclose@@GLIBC_2.2.5
/usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/broadcaster.dir/build.make:122: recipe for target ‘broadcaster’ failed
make[2]: *** [broadcaster] Error 1
make[2]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
CMakeFiles/Makefile2:76: recipe for target ‘CMakeFiles/broadcaster.dir/all’ failed
make[1]: *** [CMakeFiles/broadcaster.dir/all] Error 2
make[1]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2
make: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’

Try linking libwebrtc directly to the broadcaster.

CMakeLists.txt:

target_link_libraries(
${LIBWEBRTC_BINARY_PATH}/libwebrtc${CMAKE_STATIC_LIBRARY_SUFFIX}

)

The error changes to:

/usr/bin/ld: broadcaster: hidden symbol `SSLeay’ in /home/sumitj/webrtc-checkout-m84/src/out/m84/obj/libwebrtc.a(crypto.o) is referenced by DSO

/usr/bin/ld: final link failed: Bad value

collect2: error: ld returned 1 exit status

CMakeFiles/broadcaster.dir/build.make:123: recipe for target ‘broadcaster’ failed

make[2]: *** [broadcaster] Error 1

make[2]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’

CMakeFiles/Makefile2:76: recipe for target ‘CMakeFiles/broadcaster.dir/all’ failed

make[1]: *** [CMakeFiles/broadcaster.dir/all] Error 2

make[1]: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’

Makefile:129: recipe for target ‘all’ failed

make: *** [all] Error 2

make: Leaving directory ‘/home/sumitj/bodyline/third_party/mediasoup-broadcaster-demo/build’

I built with " -DCMAKE_CXX_FLAGS="-fvisibility=hidden" to see if it made a difference but got the same error.

After trying a lot of things and getting linker errors, everything now works magically. I am not sure what changed but most likely nuking away the build/ directory and clean building it did it.

So to summarize, this is the diff you suggested and worked:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 039262a…d30b5ca 100644
— a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC

# Public (interface) dependencies.
target_link_libraries(${PROJECT_NAME} PUBLIC

+ {LIBWEBRTC_BINARY_PATH}/libwebrtc{CMAKE_STATIC_LIBRARY_SUFFIX}
${CPR_LIBRARIES}
mediasoupclient
webrtc_broadcaster
diff --git a/deps/libmediasoupclient/include/Logger.hpp b/deps/libmediasoupclient/include/Logger.hpp
index beb2cfa…7aef2ae 100644
— a/deps/libmediasoupclient/include/Logger.hpp
+++ b/deps/libmediasoupclient/include/Logger.hpp
@@ -52,7 +52,7 @@ namespace mediasoupclient
class Logger
{
public:
- enum class LogLevel : uint8_t
+ enum class LogLevel : u_int8_t
{
LOG_NONE = 0,
LOG_ERROR = 1,
diff --git a/deps/libwebrtc/CMakeLists.txt b/deps/libwebrtc/CMakeLists.txt
index dd4dce0…3c923b7 100644
— a/deps/libwebrtc/CMakeLists.txt
+++ b/deps/libwebrtc/CMakeLists.txt
@@ -10,8 +10,8 @@ set(SOURCE_FILES
test/testsupport/ivf_video_frame_generator.cc
test/testsupport/file_utils.cc
test/testsupport/file_utils_override.cc
- test/testsupport/ios_file_utils.mm
- test/testsupport/mac_file_utils.mm
+ #test/testsupport/ios_file_utils.mm
+ #test/testsupport/mac_file_utils.mm
)

1 Like

Yes, that helps sometimes.

Happy to hear it worked!

enum class LogLevel : uint8_t

This is c++11 compliant. I don’t know the reason why it may fail.

deps/libwebrtc/CMakeLists.txt

I’ve made .mm files compilation dependant on architecture.

+ {LIBWEBRTC_BINARY_PATH}/libwebrtc{CMAKE_STATIC_LIBRARY_SUFFIX}

Can you please try this instead?

# Public (interface) dependencies.
target_link_libraries(${PROJECT_NAME} PUBLIC
    ${CMAKE_DL_LIBS}
	${CPR_LIBRARIES}
	mediasoupclient
	webrtc_broadcaster
)

This is, add ${CMAKE_DL_LIBS}.

I still get an error:

[ 81%] **Linking CXX executable broadcaster**
/usr/bin/ld: /home/sumitj/webrtc-checkout-m84/src/out/m84/obj/libwebrtc.a(latebindingsymboltable_linux.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/broadcaster.dir/build.make:122: recipe for target 'broadcaster' failed
make[2]: *** [broadcaster] Error 1

When I print out the cmake variables I see this which means libwebrtc is not linked:

{LIBWEBRTC_BINARY_PATH}/libwebrtc{CMAKE_STATIC_LIBRARY_SUFFIX}: /home/sumitj/webrtc-checkout-m84/src/out/m84/obj/libwebrtc.a

${CMAKE_DL_LIBS}: dl

I think the include is missing confusing the compiler. I tried adding #include <cstdint> and uint8_t works fine.

Can you send a PR with that include please?

@im-sj,

Can you please try with CMAKE_DL_LIBS as the last element in target_link_libraries? I cannot try this in linux right now.

I tried this and replied to in my comment here:

It did not work.

Any update on this?

${CMAKE_DL_LIBS} did not work. Though your earlier suggestion did work:
${LIBWEBRTC_BINARY_PATH}/libwebrtc${CMAKE_STATIC_LIBRARY_SUFFIX}

So should I create a pr for this?

Yes please, indicating the problem that it fixes.

Thanks.

Thanks. Done: https://github.com/versatica/mediasoup-broadcaster-demo/pull/19

1 Like