title: How can dlerror() return NULL if dlopen() fails?
body: <p>I am working on system that loads all <code>*.so</code> modules library automatically by call a script.</p>
  
  <p>I tried to update one of the modules to support XML-RPC. I used the library <code>ibxmlrpc-c3-dev</code> on Ubuntu 10.10. The problem that <code>dlopen()</code> fails after my changes and <code>dlerror()</code> returns NULL. The compilation does not return any error. </p>
  
  <p>How can I debug and fix this issue? Below is the code:</p>
  
  <pre><code>#include "stdlib.h"
  #include "stdio.h"
  #ifndef WIN32
  #include "unistd.h"
  #endif
  
  #include "xmlrpc-c/base.h"
  #include "xmlrpc-c/server.h"
  #include "xmlrpc-c/server_abyss.h"
  
  #include "config.h"  /* information about this build environment */
  </code></pre>
  
  <p>And, I added this function , most of the lines are commented out ,even though <code>dlopen()</code> fails:</p>
  
  <pre><code>int RPC_Server(int           const port) {
  
     // xmlrpc_server_abyss_parms serverparm;
      //xmlrpc_registry * registryP;
      xmlrpc_env env;
  
  
  
      xmlrpc_env_init(&amp;env);
  
      //registryP = xmlrpc_registry_new(&amp;env);
  
     // xmlrpc_registry_add_method(
      //    &amp;env, registryP, NULL, "sample.add", &amp;sample_add, NULL);
  
      /* In the modern form of the Abyss API, we supply parameters in memory
         like a normal API.  We select the modern form by setting
         config_file_name to NULL:
      */
    //  serverparm.config_file_name = NULint
      RPC_Server(int           const port) {
  
         // xmlrpc_server_abyss_parms serverparm;
          //xmlrpc_registry * registryP;
          xmlrpc_env env;
  
  
  
          xmlrpc_env_init(&amp;env);
  
          //registryP = xmlrpc_registry_new(&amp;env);
  
         // xmlrpc_registry_add_method(
          //    &amp;env, registryP, NULL, "sample.add", &amp;sample_add, NULL);
  
          /* In the modern form of the Abyss API, we supply parameters in memory
             like a normal API.  We select the modern form by setting
             config_file_name to NULL:
          */
        //  serverparm.config_file_name = NULL;
         // serverparm.registryP        = registryP;
         // serverparm.port_number      = port;
         // serverparm.log_file_name    = "/tmp/xmlrpc_log";
  
         // printf("Running XML-RPC server...\n");
  
         // xmlrpc_server_abyss(&amp;env, &amp;serverparm, XMLRPC_APSIZE(log_file_name));
  
          /* xmlrpc_server_abyss() never returns */
  
          return 0;
      }L;
     // serverparm.registryP        = registryP;
     // serverparm.port_number      = port;
     // serverparm.log_file_name    = "/tmp/xmlrpc_log";
  
     // printf("Running XML-RPC server...\n");
  
     // xmlrpc_server_abyss(&amp;env, &amp;serverparm, XMLRPC_APSIZE(log_file_name));
  
      /* xmlrpc_server_abyss() never returns */
  
      return 0;
  }
  </code></pre>
  
  <p>and this is the code the is used to load modules</p>
  
  <pre><code>#ifndef RTLD_NOW
  
  #define RTLD_NOW DL_LAZY
  #endif   
  void* handle;
  char* error;
  
  
  handle=dlopen(mod-&gt;binary_file, RTLD_NOW); 
  
  if (!handle){
  LOG( " could not open file [%s]: %s\n",
      mod_cfg-&gt;binary_file, dlerror() );
  return 0;
  }
  </code></pre>