Hi Bill,<br><br><div class="gmail_quote">On Sat, Aug 21, 2010 at 7:39 PM, Schwab,Wilhelm K <span dir="ltr">&lt;<a href="mailto:bschwab@anest.ufl.edu">bschwab@anest.ufl.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
It has been a long day, and it might not have needed to be so.  Within 15 minutes of seeing &quot;undefined symbol: libusb_close&quot; from dlerror(), I had the problem not only diagnosed but fixed; seeing the error in something related to USB support was enough to suggest I needed to link that library into the .so I was trying to load.  I was still guessing, but it was an educated guess based on a concrete lead.<br>

<br>
Is there a way to get such diagnostic information without hacking the vm source?  If not, please consider the following as a proposed patch.  I have tried to strike a balance between seeing enough to make sense of errant plugin paths and giving detailed information about failures when given an absolute path.  Behavior changes (I intend/think) only if something won&#39;t load (it says what it was trying to do) and if the library is specified by absolute path, in which case it gives diagnostic output on any failure to load.<br>
</blockquote><div><br></div><div>What I do is manually repeat the link command using options that will cause the linker to complain about unresolved symbols. You&#39;ll get some false positives (dynamically-linked runtime routines) but you&#39;ll also get any actually undefined symbols.  Use  -Wl,--warn-unresolved-symbols -Wl,--no-allow-shlib-undefined when manually repeating the link command.</div>
<div><br></div><div>So while this is after the fact you should try remaking your plugin with the libusb support missing, copy the link command and repeat it adding -Wl,--warn-unresolved-symbols -Wl,--no-allow-shlib-undefined and this tie you should see the link fail while listing libusb_close et al.</div>
<div><br></div><div>HTH</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Bill<br>
<br>
<br>
( Squeak-...-src/unix/vm/sqUnixExternalPrims.c )<br>
static void *tryLoadModule(char *in, char *name)<br>
{<br>
  char path[PATH_MAX], *out= path;<br>
  void *handle= 0;<br>
  int c;<br>
  while ((c= *in++) &amp;&amp; &#39;:&#39; != c) {      /* copy next plugin path to path[] */<br>
    switch (c) {<br>
    case &#39;%&#39;:<br>
      if (&#39;n&#39; == *in || &#39;N&#39; == *in) {   /* replace %n with name of plugin */<br>
        ++in;<br>
        strcpy(out, name);<br>
        out += strlen(name);<br>
        continue;<br>
      }<br>
      if (&#39;%&#39; == *in) {<br>
        ++in;<br>
        *out++= &#39;%&#39;;<br>
        continue;<br>
      }<br>
      /* fall through... */<br>
    default:<br>
      *out++= c;<br>
      continue;<br>
    }<br>
  }<br>
  sprintf(out, &quot;/&quot; MODULE_PREFIX &quot;%s&quot; MODULE_SUFFIX, name);<br>
  handle= dlopen(path, RTLD_NOW | RTLD_GLOBAL);<br>
  fdebugf((stderr, &quot;tryLoading(%s) = %p\n&quot;, path, handle));<br>
<br>
        // 8-10 wks - no silent failures<br>
        if( !handle ){<br>
                // 8-10 - if a load fails, tell the user what we tried to load:<br>
                fprintf(stdout, &quot;Load failed for: %s\n&quot;, path);<br>
<br>
                // 8-10 - is the given path absolute?  If so, try again with it<br>
                // as given and report diagnostic information if it fails.<br>
                if( (int)(name[0])==47 ) {<br>
                        handle=dlopen(name, RTLD_NOW | RTLD_GLOBAL);<br>
                        fprintf(stdout, &quot;Load-by-name(%s) = %p\n&quot;, name, handle);<br>
                        if(!handle){<br>
                                fprintf(stdout,&quot;Error loading library: %s\n&quot;,dlerror());<br>
                        }<br>
                }<br>
        }<br>
<br>
  if (!handle) {<br>
    struct stat buf;<br>
    if ((0 == stat(path, &amp;buf)) &amp;&amp; ! S_ISDIR(buf.st_mode))<br>
      fprintf(stderr, &quot;%s\n&quot;, dlerror());<br>
  }<br>
<br>
  return handle;<br>
}<br>
<br>
________________________________________<br>
From: <a href="mailto:pharo-project-bounces@lists.gforge.inria.fr">pharo-project-bounces@lists.gforge.inria.fr</a> [<a href="mailto:pharo-project-bounces@lists.gforge.inria.fr">pharo-project-bounces@lists.gforge.inria.fr</a>] On Behalf Of Schwab,Wilhelm K [<a href="mailto:bschwab@anest.ufl.edu">bschwab@anest.ufl.edu</a>]<br>

Sent: Saturday, August 21, 2010 8:19 PM<br>
To: <a href="mailto:Pharo-project@lists.gforge.inria.fr">Pharo-project@lists.gforge.inria.fr</a>; <a href="mailto:vm-dev@lists.squeakfoundation.org">vm-dev@lists.squeakfoundation.org</a><br>
Subject: [Pharo-project] Linux vm<br>
<br>
Hello all,<br>
<br>
Is there a way to get the pre-compiled linux vm to describe what the full path is to a library it is trying to load?    I can hack the source to do so, but then I start wondering what I might have disturbed in the process.  Out of the box, all I get is an external library with a nil handle and no clue what did or did not happen.<br>

<br>
At various points in my struggle today, I saw what looked like a tendency to load plugins from the vmpath//so.pluginName (two slashes rather than one).  It raises the question of whether the code is adding an extra slash when it is not given an explicit plugins path??  The separate concern is that I need information about what is happening when one of my libraries fails to load.<br>

<br>
One possibility is that a particular .so can&#39;t load.  How would I find out whether that this is case?  Is there a way to test load it or to get the vm to tell me the cause of a failure to load it?<br>
<br>
Bill<br>
<br>
<br>
_______________________________________________<br>
Pharo-project mailing list<br>
<a href="mailto:Pharo-project@lists.gforge.inria.fr">Pharo-project@lists.gforge.inria.fr</a><br>
<a href="http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project" target="_blank">http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project</a><br>
</blockquote></div><br>