checking whether a statically linked program can dlopen itself… hangs

I’ve had this issue many times over when running “./configure” scripts on my Linux From Scratch 6.7 system:

checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself...

The script will then hang at the “checking whether a statically linked program can dlopen itself…” step and will not exit until I terminate the process (CTRL+C).

The configure script is typically creating a C program to test dlopen, like such:

int main ()
{
  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
  int status = $lt_dlunknown;
  if (self)
    {
      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
      else
        {
          if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
          else puts (dlerror ());
        }
      /* dlclose (self); */
    }
  else
    puts (dlerror ());

  return status;
}

where the $variables are provided by shell script.

Here’s a quick fix that works for me:

 int main ()
 {
   void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
+  int status = $lt_dlunknown; return status;
   if (self)
     {
       if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;

It doesn’t return a valid test result, but at least you’ll be able to finish configuring your program.

Leave a Reply

Your email address will not be published. Required fields are marked *