title: creating shared library linker undefined reference to
body: <p>I build a shared library using</p>
  
  <pre><code> arm-linux-gnueabi-g++ -Wall -fPIC -c -I../../../onvifgen -I. *.cpp -include openssl/all.h -fpermissive -DWITH_OPENSSL
   arm-linux-gnueabi-g++ -shared -fPIC -Wl,-soname,libonvif.so.1 -o libonvif.so.1.0   *.o
   ln -sf libonvif.so.1.0 libonvif.so.1
   ln -sf libonvif.so.1.0 libonvif.so
  </code></pre>
  
  <p>When I try to use the library I get a lot of</p>
  
  <pre><code> ../../../../binaries/lib/libonvif.so: undefined reference to 
  </code></pre>
  
  <p>This is the command I use</p>
  
  <pre><code> arm-linux-gnueabi-g++ -I../../../../binaries/include -I../../../include -fpermissive -include ../../../../binaries/include/openssl/all.h -w -o test1 onvifclient.cpp -L../../../../binaries/lib -lonvif -lssl -lcrypto -lpthread -DWITH_OPENSSL
  </code></pre>
  
  <p>As shown in the command -lonvif is after the input file onvifclient.cpp so the linker should find it.</p>
  
  <p><strong>Using a static library from the same object files .o works and the linker produce the executable.</strong></p>
  
  <p>All the answers I found on SO, are related to the ordering.</p>
  
  <p>More about the errors:</p>
  
  <pre><code>../../../../binaries/lib/libonvif.so: undefined reference to `ReceiverBindingService::CreateReceiver(_trv__CreateReceiver*, _trv__CreateReceiverResponse*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `PullPointSubscriptionBindingService::PullMessages(_tev__PullMessages*, _tev__PullMessagesResponse*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `ReceiverBindingService::GetReceiver(_trv__GetReceiver*, _trv__GetReceiverResponse*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `RecordingBindingService::GetRecordingJobState(_trc__GetRecordingJobState*, _trc__GetRecordingJobStateResponse*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `PullPointSubscriptionBindingService::Renew_(_wsnt__Renew*, _wsnt__RenewResponse*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `MediaBindingService::GetVideoEncoderConfigurations(_trt__GetVideoEncoderConfigurations*, _trt__GetVideoEncoderConfigurationsResponse*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `wsddService::Resolve(wsdd__ResolveType*)'
  ../../../../binaries/lib/libonvif.so: undefined reference to `MediaBindingService::GetAudioDecoderConfiguration_(_trt__GetAudioDecoderConfiguration*, _trt__GetAudioDecoderConfigurationResponse*)'
  + 100+ more errors but other functions.
  </code></pre>
  
  <p>All this functions are found in the cpp files and defined right.</p>
  
  <p>using <code>nm libonvif.so -C| grep MediaBindingService::GetVideoEncoderConfigurations</code></p>
  
  <p>I get the folwing result.</p>
  
  <pre><code>     U MediaBindingService::GetVideoEncoderConfigurations(_trt__GetVideoEncoderConfigurations*, _trt__GetVideoEncoderConfigurationsResponse*)
       U MediaBindingService::GetVideoEncoderConfigurations_(_trt__GetVideoEncoderConfigurations*, _trt__GetVideoEncoderConfigurationsResponse*)
  </code></pre>
  
  <p><code>MediaBindingService::GetVideoEncoderConfigurations</code> is a pure virtual function defined inside the class as:</p>
  
  <pre><code>virtual int GetVideoEncoderConfigurations(_trt__GetVideoEncoderConfigurations *trt__GetVideoEncoderConfigurations, _trt__GetVideoEncoderConfigurationsResponse *trt__GetVideoEncoderConfigurationsResponse) =0;
  </code></pre>