Statically link core_audio_utility_win to webrtc

200 views
Skip to first unread message

Andrej Staruch

unread,
Jun 24, 2019, 7:48:22 AM6/24/19
to discuss-webrtc
Hello,
we are statically building native WebRTC (branch 71) with the following arguments:

gn gen out\Debug --args="rtc_enable_sctp=false libyuv_include_tests=false use_cxx11=false is_component_build=false rtc_build_ssl=false rtc_build_tools=false is_clang=true use_lld=false treat_warnings_as_errors=false rtc_include_tests=false rtc_build_examples=false use_custom_libcxx=false use_custom_libcxx_for_host=false rtc_enable_protobuf=false use_rtti=true rtc_ssl_root=\"C:\\openssl111\\include\" target_cpu=\"x86\" target_os=\"win\" " \
&& ninja -C out/Debug 

The platform is Win1803, SDK 17134. 

The problem is, that when we'd like to use modules\audio_device\win\core_audio_utility_win.h, we've got a linking problem:

Minimum example with a problem:

#include <iostream>
#include "modules/audio_device/win/core_audio_utility_win.h"


int main()
{
bool supported = webrtc::webrtc_win::core_audio_utility::IsSupported();
std::cout << "core_audio_utility is " << (supported ? "supported" : "unsupported") << std::endl;
return 0;
}


main.cpp.obj : error LNK2019: unresolved external symbol "bool __cdecl webrtc::webrtc_win::core_audio_utility::IsSupported(void)" (?IsSupported@core_audio_utility@webrtc_win@webrtc@@YA_NXZ) referenced in function _main


CMakeList.txt
cmake_minimum_required(VERSION 3.12)
project(test_audio_project)
set(CMAKE_CXX_STANDARD 14)
add_executable(test_audio_project main.cpp)
set(CMAKE_CXX_FLAGS "/EHsc /DNOMINMAX /DWEBRTC_WIN /DWIN32_LEAN_AND_MEAN /D_UNICODE /DUNICODE")
target_include_directories(test_audio_project PRIVATE
${WEBRTC_ROOT_DIR}
${WEBRTC_ROOT_DIR}/third_party/abseil-cpp
${WEBRTC_ROOT_DIR}/third_party/libyuv/include
)
target_link_libraries(test_audio_project PRIVATE
${WEBRTC_ROOT_DIR}/out/${CMAKE_BUILD_TYPE}/obj/webrtc.lib
)


When I inspect the
webrtc.lib with use of DUMPBIN, there isn't included namespace core_audio_utility, thus I assume, we are not compiling it or we are missing some important flag. I've read a whole gn args out\Debug --list but I didn't find anything relevant regarding this case.

Do you have please any tips on how to resolve this problem? Thanks


Andrej Staruch

unread,
Jun 24, 2019, 11:10:01 AM6/24/19
to discuss-webrtc
After several tries and endless search, I've found a workaround which works. This is a patch if anybody will be interested in the future:
$ git diff                                                                
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index b690050981..96aed132f0 100644                                       
--- a/modules/audio_device/BUILD.gn                                       
+++ b/modules/audio_device/BUILD.gn                                       
@@ -219,6 +219,8 @@ rtc_source_set("audio_device_impl") {                 
     "../../system_wrappers:metrics",                                     
     "../utility",                                                        
     "//third_party/abseil-cpp/absl/memory",                              
+    ":audio_device_module_from_input_and_output",                        
+    ":windows_core_audio_utility",                                       
   ]                                                                      
   if (rtc_include_internal_audio_device && is_ios) {                     
     deps += [ ":audio_device_ios_objc" ]                                 
                                                                          
Reply all
Reply to author
Forward
0 new messages