aisouard / libwebrtc

:package: Google's WebRTC implementation in a single static library.
https://axel.isouard.fr/libwebrtc
Apache License 2.0
641 stars 190 forks source link

Undefined symbols for architecture x86_64 #69

Closed BeiKeJieDeLiuLangMao closed 6 years ago

BeiKeJieDeLiuLangMao commented 6 years ago

I am a new bee for c++, i build libwebrtc in my mac, change PKG_CONFIG_PATH to be /path/to/libwebrtc/out, and change LibWebRTC.pc like follow

prefix=/usr/local
exec_prefix=${prefix}
libdir=/path/to/libwebrtc/out/lib
includedir=/path/to/libwebrtc/out/include

Name: LibWebRTC
Description: Google's native WebRTC implementation shipped into a single library
Version: 0.0.1-rc.4
Libs: -L/path/to//libwebrtc/out/lib -lwebrtc
Libs.private: -L/System/Library/Frameworks AudioToolbox CoreAudio CoreFoundation CoreGraphics Foundation
Cflags: -I${includedir} -DWEBRTC_POSIX -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++0x

But when i execute this command to run your sample, a error happened. $ g++pkg-config --cflags LibWebRTCmain.cpp -o mainpkg-config --libs LibWebRTC``

Undefined symbols for architecture x86_64:
  "_AudioConvertHostTimeToNanos", referenced from:
      webrtc::AudioDeviceMac::implDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::implInDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
  "_AudioConverterDispose", referenced from:
      webrtc::AudioDeviceMac::StopRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StopPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::HandleStreamFormatChange(unsigned int, AudioObjectPropertyAddress) in libwebrtc.a(audio_device_mac.o)
  "_AudioConverterFillComplexBuffer", referenced from:
      webrtc::AudioDeviceMac::implDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::CaptureWorkerThread() in libwebrtc.a(audio_device_mac.o)
  "_AudioConverterNew", referenced from:
      webrtc::AudioDeviceMac::SetDesiredPlayoutFormat() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::HandleStreamFormatChange(unsigned int, AudioObjectPropertyAddress) in libwebrtc.a(audio_device_mac.o)
  "_AudioDeviceCreateIOProcID", referenced from:
      webrtc::AudioDeviceMac::InitPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitRecording() in libwebrtc.a(audio_device_mac.o)
  "_AudioDeviceDestroyIOProcID", referenced from:
      webrtc::AudioDeviceMac::StopRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StopPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::implDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::implInDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
  "_AudioDeviceStart", referenced from:
      webrtc::AudioDeviceMac::StartRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StartPlayout() in libwebrtc.a(audio_device_mac.o)

  "_AudioDeviceStop", referenced from:
      webrtc::AudioDeviceMac::StopRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StopPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::implDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::implInDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
  "_AudioGetCurrentHostTime", referenced from:
      webrtc::AudioDeviceMac::implDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::implInDeviceIOProc(AudioBufferList const*, AudioTimeStamp const*) in libwebrtc.a(audio_device_mac.o)
  "_AudioHardwareUnload", referenced from:
      webrtc::AudioDeviceMac::Terminate() in libwebrtc.a(audio_device_mac.o)
  "_AudioObjectAddPropertyListener", referenced from:
      webrtc::AudioDeviceMac::Init() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitRecording() in libwebrtc.a(audio_device_mac.o)
  "_AudioObjectGetPropertyData", referenced from:
      webrtc::AudioDeviceMac::InitDevice(unsigned short, unsigned int&, bool) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::GetNumberDevices(unsigned int, unsigned int*, unsigned int) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::GetDeviceName(unsigned int, unsigned short, char*) in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::SetDesiredPlayoutFormat() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::HandleDeviceChange() in libwebrtc.a(audio_device_mac.o)
      ...
  "_AudioObjectGetPropertyDataSize", referenced from:
      webrtc::AudioDeviceMac::GetNumberDevices(unsigned int, unsigned int*, unsigned int) in libwebrtc.a(audio_device_mac.o)
  "_AudioObjectHasProperty", referenced from:
      webrtc::AudioDeviceMac::InitPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StopPlayout() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioMixerManagerMac::SpeakerVolume(unsigned int&) const in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SpeakerMute(bool&) const in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::MicrophoneMute(bool&) const in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::MicrophoneVolume(unsigned int&) const in libwebrtc.a(audio_mixer_manager_mac.o)
  "_AudioObjectIsPropertySettable", referenced from:
      webrtc::AudioMixerManagerMac::SetSpeakerVolume(unsigned int) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SpeakerVolumeIsAvailable(bool&) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SpeakerMuteIsAvailable(bool&) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SetSpeakerMute(bool) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::MicrophoneMuteIsAvailable(bool&) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SetMicrophoneMute(bool) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::MicrophoneVolumeIsAvailable(bool&) in libwebrtc.a(audio_mixer_manager_mac.o)
      ...
  "_AudioObjectRemovePropertyListener", referenced from:
      webrtc::AudioDeviceMac::Terminate() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StopRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::StopPlayout() in libwebrtc.a(audio_device_mac.o)
  "_AudioObjectSetPropertyData", referenced from:
      webrtc::AudioDeviceMac::Init() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::SetDesiredPlayoutFormat() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::InitRecording() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioMixerManagerMac::SetSpeakerVolume(unsigned int) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SetSpeakerMute(bool) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SetMicrophoneMute(bool) in libwebrtc.a(audio_mixer_manager_mac.o)
      webrtc::AudioMixerManagerMac::SetMicrophoneVolume(unsigned int) in libwebrtc.a(audio_mixer_manager_mac.o)
      ...
  "_CFBundleGetIdentifier", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libwebrtc.a(logging.o)
  "_CFBundleGetMainBundle", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libwebrtc.a(logging.o)
  "_CFPreferencesGetAppBooleanValue", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libwebrtc.a(logging.o)
  "_CFRelease", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libwebrtc.a(logging.o)
  "_CFStringCreateWithCString", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libwebrtc.a(logging.o)
  "_CGEventSourceKeyState", referenced from:
      webrtc::AudioDeviceMac::CaptureWorkerThread() in libwebrtc.a(audio_device_mac.o)
      webrtc::AudioDeviceMac::KeyPressed() in libwebrtc.a(audio_device_mac.o)
  "_NSOSStatusErrorDomain", referenced from:
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
  "_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
      objc-class-ref in libwebrtc.a(scoped_autorelease_pool.o)
      objc-class-ref in libwebrtc.a(maccocoathreadhelper.o)
  "_OBJC_CLASS_$_NSError", referenced from:
      objc-class-ref in libwebrtc.a(logging_mac.o)
  "_OBJC_CLASS_$_NSObject", referenced from:
      objc-class-ref in libwebrtc.a(maccocoathreadhelper.o)
  "_OBJC_CLASS_$_NSThread", referenced from:
      objc-class-ref in libwebrtc.a(maccocoathreadhelper.o)
  "boost::system::system_category()", referenced from:
      boost::asio::error::get_system_category() in main-f1e0df.o
      boost::system::error_code::error_code() in main-f1e0df.o
      ___cxx_global_var_init.3 in main-f1e0df.o
  "boost::system::generic_category()", referenced from:
      boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in main-f1e0df.o
      boost::system::error_category::std_category::equivalent(std::__1::error_code const&, int) const in main-f1e0df.o
      boost::system::errc::make_error_condition(boost::system::errc::errc_t) in main-f1e0df.o
      ___cxx_global_var_init.1 in main-f1e0df.o
      ___cxx_global_var_init.2 in main-f1e0df.o
  "_kCFAllocatorDefault", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libwebrtc.a(logging.o)
  "_objc_msgSend", referenced from:
      rtc::ScopedAutoreleasePool::ScopedAutoreleasePool() in libwebrtc.a(scoped_autorelease_pool.o)
      rtc::ScopedAutoreleasePool::ScopedAutoreleasePool() in libwebrtc.a(scoped_autorelease_pool.o)
      rtc::ScopedAutoreleasePool::~ScopedAutoreleasePool() in libwebrtc.a(scoped_autorelease_pool.o)
      rtc::ScopedAutoreleasePool::~ScopedAutoreleasePool() in libwebrtc.a(scoped_autorelease_pool.o)
      rtc::InitCocoaMultiThreading() in libwebrtc.a(maccocoathreadhelper.o)
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Did i make a mistake with LibWebRTC.pc or maybe others?

jmillan commented 5 years ago

Hi @BeiKeJieDeLiuLangMao,

I'm experiencing a similar issue:

Undefined symbols for architecture x86_64:
  "_CFBundleGetIdentifier", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity) in libwebrtc.a(logging.o)
  "_CFBundleGetMainBundle", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity) in libwebrtc.a(logging.o)
  "_CFPreferencesGetAppBooleanValue", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity) in libwebrtc.a(logging.o)
  "_CFRelease", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity) in libwebrtc.a(logging.o)
  "_CFStringCreateWithCString", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity) in libwebrtc.a(logging.o)
  "_NSOSStatusErrorDomain", referenced from:
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
  "_OBJC_CLASS_$_NSError", referenced from:
      objc-class-ref in libwebrtc.a(logging_mac.o)
  "_OBJC_CLASS_$_NSObject", referenced from:
      objc-class-ref in libwebrtc.a(thread_darwin.o)
  "_OBJC_CLASS_$_NSThread", referenced from:
      objc-class-ref in libwebrtc.a(thread_darwin.o)
  "_kCFAllocatorDefault", referenced from:
      rtc::LogMessage::OutputToDebug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rtc::LoggingSeverity) in libwebrtc.a(logging.o)
  "_objc_autoreleasePoolPop", referenced from:
      rtc::ThreadManager::ThreadManager() in libwebrtc.a(thread_darwin.o)
      rtc::ThreadManager::ThreadManager() in libwebrtc.a(thread_darwin.o)
      rtc::Thread::PreRun(void*) in libwebrtc.a(thread_darwin.o)
      rtc::Thread::ProcessMessages(int) in libwebrtc.a(thread_darwin.o)
  "_objc_autoreleasePoolPush", referenced from:
      rtc::ThreadManager::ThreadManager() in libwebrtc.a(thread_darwin.o)
      rtc::ThreadManager::ThreadManager() in libwebrtc.a(thread_darwin.o)
      rtc::Thread::PreRun(void*) in libwebrtc.a(thread_darwin.o)
      rtc::Thread::ProcessMessages(int) in libwebrtc.a(thread_darwin.o)
  "_objc_msgSend", referenced from:
      rtc::ThreadManager::ThreadManager() in libwebrtc.a(thread_darwin.o)
      rtc::ThreadManager::ThreadManager() in libwebrtc.a(thread_darwin.o)
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
  "_objc_release", referenced from:
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
  "_objc_retainAutorelease", referenced from:
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
  "_objc_retainAutoreleasedReturnValue", referenced from:
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)

May you please comment on your solution?

jmillan commented 5 years ago

Reduced the previous undefined symbol list to:

Undefined symbols for architecture x86_64:
  "_NSOSStatusErrorDomain", referenced from:
      rtc::DescriptionFromOSStatus(int) in libwebrtc.a(logging_mac.o)
  "_OBJC_CLASS_$_NSError", referenced from:
      objc-class-ref in libwebrtc.a(logging_mac.o)
  "_OBJC_CLASS_$_NSThread", referenced from:
      objc-class-ref in libwebrtc.a(thread_darwin.o)
ld: symbol(s) not found for architecture x86_64

By adding the following lines to the CMakeLists.txt:

  find_library(CORE_FOUNDATION CoreFoundation)
  find_library(APPLICATION_SERVICES ApplicationServices)
  find_library(CORE_SERVICES CoreServices)

  set(EXTRA_LIBS ${CORE_FOUNDATION} ${APPLICATION_SERVICES} ${CORE_SERVICES})

Still looking at it

jmillan commented 5 years ago

Finally linked by:

  find_library(CORE_FOUNDATION Foundation)
  find_library(APPLICATION_SERVICES ApplicationServices)
  find_library(CORE_SERVICES CoreServices)

  set(EXTRA_LIBS ${CORE_FOUNDATION} ${APPLICATION_SERVICES} ${CORE_SERVICES})
hkirat commented 3 years ago

@jmillan could you elaborate on where you had to add the CMakeLists.txt file? Was it the webrc/src folder? Or inside the project where you were trying to use webrtc?

jmillan commented 3 years ago

@hkirat,

In the project where I was using webrtc.