0

When looking into my static library that I'm using, I see that my symbol is defined:

$ nm ~/personal/wc/libwebrtc2/out/lib/libwebrtc.a --demangle --defined-only | grep 'adaptedvideotracksource.o' -A 100 | grep 'rtc::AdaptedVideoTrackSource' | sort | uniq
no symbols
...
no symbols
0000000000000000 T rtc::AdaptedVideoTrackSource::AdaptedVideoTrackSource()
0000000000000080 T rtc::AdaptedVideoTrackSource::AdaptedVideoTrackSource(int)
0000000000000100 T rtc::AdaptedVideoTrackSource::GetStats(webrtc::VideoTrackSourceInterface::Stats*)
0000000000000150 T rtc::AdaptedVideoTrackSource::OnFrame(webrtc::VideoFrame const&)
0000000000000230 T rtc::AdaptedVideoTrackSource::apply_rotation()
0000000000000260 T rtc::AdaptedVideoTrackSource::AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*, rtc::VideoSinkWants const&)
00000000000002b0 T rtc::AdaptedVideoTrackSource::OnSinkWantsChanged(rtc::VideoSinkWants const&)
00000000000002d0 T non-virtual thunk to rtc::AdaptedVideoTrackSource::AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*, rtc::VideoSinkWants const&)
0000000000000320 T rtc::AdaptedVideoTrackSource::RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*)
0000000000000370 T non-virtual thunk to rtc::AdaptedVideoTrackSource::RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*)
00000000000003c0 T rtc::AdaptedVideoTrackSource::AdaptFrame(int, int, long long, int*, int*, int*, int*, int*, int*)
00000000000004b0 T rtc::AdaptedVideoTrackSource::~AdaptedVideoTrackSource()
00000000000004c0 T rtc::AdaptedVideoTrackSource::~AdaptedVideoTrackSource()
0000000000000630 T non-virtual thunk to rtc::AdaptedVideoTrackSource::~AdaptedVideoTrackSource()
0000000000000640 T non-virtual thunk to rtc::AdaptedVideoTrackSource::~AdaptedVideoTrackSource()
0000000000000650 T non-virtual thunk to rtc::AdaptedVideoTrackSource::~AdaptedVideoTrackSource()
0000000000000660 T non-virtual thunk to rtc::AdaptedVideoTrackSource::~AdaptedVideoTrackSource()
0000000000000668 S vtable for rtc::AdaptedVideoTrackSource
$ nm ~/personal/wc/libwebrtc2/out/lib/libwebrtc.a --defined-only --just-symbol-name  | grep 'adaptedvideotracksource.o' -A 100 | grep 'rtc23AdaptedVideoTrackSource' | sort | uniq
no symbols
...
no symbols
__ZN3rtc23AdaptedVideoTrackSource10AdaptFrameEiixPiS1_S1_S1_S1_S1_
__ZN3rtc23AdaptedVideoTrackSource10RemoveSinkEPNS_18VideoSinkInterfaceIN6webrtc10VideoFrameEEE
__ZN3rtc23AdaptedVideoTrackSource14apply_rotationEv
__ZN3rtc23AdaptedVideoTrackSource15AddOrUpdateSinkEPNS_18VideoSinkInterfaceIN6webrtc10VideoFrameEEERKNS_14VideoSinkWantsE
__ZN3rtc23AdaptedVideoTrackSource18OnSinkWantsChangedERKNS_14VideoSinkWantsE
__ZN3rtc23AdaptedVideoTrackSource7OnFrameERKN6webrtc10VideoFrameE
__ZN3rtc23AdaptedVideoTrackSource8GetStatsEPN6webrtc25VideoTrackSourceInterface5StatsE
__ZN3rtc23AdaptedVideoTrackSourceC2Ei
__ZN3rtc23AdaptedVideoTrackSourceC2Ev
__ZN3rtc23AdaptedVideoTrackSourceD0Ev
__ZN3rtc23AdaptedVideoTrackSourceD1Ev
__ZTVN3rtc23AdaptedVideoTrackSourceE
__ZThn16_N3rtc23AdaptedVideoTrackSource10RemoveSinkEPNS_18VideoSinkInterfaceIN6webrtc10VideoFrameEEE
__ZThn16_N3rtc23AdaptedVideoTrackSource15AddOrUpdateSinkEPNS_18VideoSinkInterfaceIN6webrtc10VideoFrameEEERKNS_14VideoSinkWantsE
__ZThn16_N3rtc23AdaptedVideoTrackSourceD0Ev
__ZThn16_N3rtc23AdaptedVideoTrackSourceD1Ev
__ZThn8_N3rtc23AdaptedVideoTrackSourceD0Ev
__ZThn8_N3rtc23AdaptedVideoTrackSourceD1Ev

Yet, when I try to compile this, I get an error that the symbol is undefined. Why is that if it says the sybmol is defined? Does this have to with the fact that it's defined as S vtable for rtc::AdaptedVideoTrackSource(uninitialized data section?) or as T (Global text symbol)?

@(#)PROGRAM:ld  PROJECT:ld64-556.6
BUILD 13:10:29 Apr  7 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
    /Users/hiphipjorge/Library/Developer/Xcode/DerivedData/TestFramework-gqjnsigwustzzraweohfnalrotum/Build/Products/Debug
    /Users/hiphipjorge/personal/wc/libwebrtc2/out/lib/
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib
Framework search paths:
    /Users/hiphipjorge/Library/Developer/Xcode/DerivedData/TestFramework-gqjnsigwustzzraweohfnalrotum/Build/Products/Debug
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
  "typeinfo for rtc::AdaptedVideoTrackSource", referenced from:
      typeinfo for webrtc::ObjcVideoTrackSource in objcvideotracksource.o
      typeinfo for webrtc::ObjcVideoTrackSource in RTCPeerConnectionFactory.o
  "typeinfo for webrtc::I420Buffer", referenced from:
      typeinfo for rtc::RefCountedObject<webrtc::I420Buffer> in corevideo_frame_buffer.o
  "typeinfo for webrtc::NativeHandleBuffer", referenced from:
      typeinfo for webrtc::CoreVideoFrameBuffer in corevideo_frame_buffer.o
  "typeinfo for cricket::VideoCapturer", referenced from:
      typeinfo for webrtc::AVFoundationVideoCapturer in avfoundationvideocapturer.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Jorge Silva
  • 4,574
  • 1
  • 23
  • 42
  • Can you remove the "--demangle" option and show the output? Maybe it's an issue with the mangled names. Did you use the same compiler to build the library and your program? – F Trias Apr 20 '20 at 23:52
  • Included the output without `--demangle` too. I did not use the same compiler. This is a static library (https://github.com/aisouard/libwebrtc). I'm using clang for my project and the library was built using `g++`. I can try to see if compiling my project with `g++` might help. – Jorge Silva Apr 21 '20 at 03:19
  • Ok, so those seem to be the same compiler, but I did use different binaries. – Jorge Silva Apr 21 '20 at 03:25
  • 1
    It complains about missing typeinfo, not symbols. Different settings for rtti on the compilation units? – Blindleistung Apr 21 '20 at 07:02
  • Have you looked at this? https://stackoverflow.com/questions/307352/g-undefined-reference-to-typeinfo – F Trias Apr 21 '20 at 11:57
  • @Blindleistung That was it. `-fno-rtti` had been used on the static library. Turned that off and it worked. – Jorge Silva Apr 21 '20 at 17:25

0 Answers0