title: Issue loading shared object functions with dlsym in C++
body: <p>I'm trying to load two functions from a shared object (.so) library i had installed, but when i compile my code i get a couple of errors when i try to use those functions, here's my code:</p>
  
  <pre><code>void G729ToPcmFilter::AudioChunkIn(AudioChunkRef&amp; inputAudioChunk){
  
      std::string s = std::to_string(inputAudioChunk-&gt;GetNumBytes());
      LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn Size =&gt; " + s));
  
      typedef struct bcg729DecoderChannelContextStruct_struct bcg729DecoderChannelContextStruct;
      void *handle;
      bcg729DecoderChannelContextStruct (*initer)(bcg729DecoderChannelContextStruct);
      void (*decoder)(void);
      char* error;
      handle = dlopen ("libbcg729.so", RTLD_LAZY);
      if (!handle) {
              LOG4CXX_ERROR(LOG.rootLog, CStdString("Couldn't load Bcg729 plugin"));
          }
      else {
              *(void **) (&amp;initer) = dlsym(handle,"initBcg729DecoderChannel");
              *(void **) (&amp;decoder) = dlsym(handle,"bcg729Decoder");
              if ((error = dlerror()) != NULL)  {
                  std::string str(error);
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("Couldn't load Bcg729 plugin's functions =&gt; "+str));
              } else {
                  const char* inputBuffer = reinterpret_cast&lt;const char*&gt;((unsigned char*)inputAudioChunk-&gt;m_pBuffer);
                  char *ret = (char*)malloc(10);
                  memcpy(ret, inputBuffer, 10);
                  char* firstFragment = ret;
                  ret = (char*)malloc(10);
                  memcpy(ret, inputBuffer+10, 10);
                  char* secondFragment = ret;
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn buffer separated into two 10 bit buffers"));
  
                  int16_t outputBuffer[80]; /* output buffer: the reconstructed signal */ 
                  int16_t outputBuffer1[80]; /* output buffer: the reconstructed signal */ 
                  uint8_t bitStream[10]; /* binary input for the decoder */
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn Buffers Created"));
  
                  bcg729DecoderChannelContextStruct *decoderChannelContext = (*initer)();
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn Decoder Initialized"));
  
                  for(int i=0; i &lt; 10 ; i++){
                      bitStream[i] = (uint8_t)atoi(&amp;firstFragment[i]);
                  }
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn First BitStream Created"));
  
                  (*decoder)(decoderChannelContext, bitStream, 1, outputBuffer);
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn First Stream Decoding DONE"));
  
                  for(int i=0; i &lt; 10 ; i++){
                      bitStream[i] = (uint8_t)atoi(&amp;secondFragment[i]);
                  }
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn Second BitStream Created"));
  
                  (*decoder)(decoderChannelContext, bitStream, 0, outputBuffer1);
  
                  LOG4CXX_ERROR(LOG.rootLog, CStdString("G729 AudioChunkIn Second Stream Decoding DONE"));
  
                  m_outputAudioChunk.reset(new AudioChunk());
                  AudioChunkDetails chunkDetails = *inputAudioChunk-&gt;GetDetails();
                  chunkDetails.m_rtpPayloadType = -1;
                  chunkDetails.m_encoding = PcmAudio;
                  chunkDetails.m_numBytes = 160;
                  short* outputBufferFinal = (short*)m_outputAudioChunk-&gt;CreateBuffer(chunkDetails);
                  for(int i = 0; i &lt; 80; i++){
                      outputBufferFinal[i] = outputBuffer[i];
                      outputBufferFinal[i+80] = outputBuffer1[1];
                  }
  
              }
      }
  }
  </code></pre>
  
  <p>I get, the following errors at compile time, I'm sure 'm passing the paramethers as declared on the .so library I'm using:</p>
  
  <pre><code>G729Codec.cpp: In member function ‘virtual void G729ToPcmFilter::AudioChunkIn(AudioChunkRef&amp;)’:
  G729Codec.cpp:173:74: error: too few arguments to function
       bcg729DecoderChannelContextStruct *decoderChannelContext = (*initer)();
                                                                            ^
  G729Codec.cpp:183:65: error: too many arguments to function
       (*decoder)(decoderChannelContext, bitStream, 1, outputBuffer);
                                                                   ^
  G729Codec.cpp:193:66: error: too many arguments to function
       (*decoder)(decoderChannelContext, bitStream, 0, outputBuffer1);
  </code></pre>
  
  <p>On the header of the libbcg729.so library, the functions are declared as follows:</p>
  
  <pre><code>BCG729_VISIBILITY bcg729DecoderChannelContextStruct *initBcg729DecoderChannel();
  BCG729_VISIBILITY void bcg729Decoder(bcg729DecoderChannelContextStruct *decoderChannelContext, uint8_t bitStream[], uint8_t frameErasureFlag, int16_t signal[]);
  </code></pre>
  
  <p>I can't figure out what I'm doing wrong, can anyone help me?</p>