Andreas: Thanks for the replies. I did all of what you told me but I got this error when trying to call the api:<br><br>&#39;External library is invalid&#39;<br><br>I even try to execute: ExternalLibrary initialize.<br><br>

However, I am not convinced why this way is better than having module: aString.<br><br>Disadvantages of this new way:<br><br>- I am &quot;coupling&quot; or &quot;hardcoding&quot; not only the library name but also the location in the file system. Perhaps I rather this be automatically done by FFI. <br>

<br>Advantages of this new way:<br>
<br>
- I can add as many names or paths as I want to my library. <br>
<br>what do you think? can you help me with the advantages and disadvantages from both alternatives?<br><br>
Thanks!<br><br>Mariano<br><br><br><br><div class="gmail_quote">On Fri, May 1, 2009 at 5:44 PM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div><br>
On 01.05.2009, at 17:48, Andreas Raab wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Bert Freudenberg wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 30.04.2009, at 23:55, Andreas Raab wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Bert Freudenberg wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 30.04.2009, at 23:22, Mariano Martinez Peck wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
  However, you can of course manually do the &quot;linking&quot; step - in the<br>
  ffi function declarations, use &quot;libopendbx.so.1&quot; as module instead<br>
  of just &quot;opendbx&quot;. This will then only work on Linux of course,<br>
  since other Unix platforms use different schemes of versioning<br>
  libraries.<br>
<br>
<br>
Indeed. That&#39;s why I don&#39;t want to change the module name.<br>
</blockquote>
Well, you can also automate this &quot;pseudo-linking&quot;. When starting up, just patch the right module name for the current platform into all the FFI declarations. That&#39;s how the OpenGL FFI bindings in Croquet work ...<br>


</blockquote>
<br>
The way this is done is purely for historical reasons (and an *extremely* bad example that should not be taught to anyone). The Right Way to do this is to have a subclass of ExternalLibrary and implement the class-side method #moduleName along the lines of:<br>


<br>
MyLibrary class&gt;&gt;moduleName<br>
&quot;Answer the module name to use for this library&quot;<br>
Smalltalk platformName = &#39;Win32&#39; ifTrue:[^&#39;MyLibrary32.dll&#39;].<br>
Smalltalk platformName = &#39;unix&#39; ifTrue:[<br>
   &quot;check various locations and versions&quot;<br>
   #(&#39;/usr/lib/libMyLibrary.so&#39;<br>
     &#39;/usr/lib/libMyLibrary.so.1&#39;<br>
     &#39;/usr/lib/libMyLibrary.so.2&#39;<br>
     &#39;/usr/share/libMyLibrary.so.1&#39;<br>
     &#39;/usr/share/libMyLibrary.so.2&#39;) do:[:location|<br>
        (FileDirectory fileExists: location) ifTrue:[^location].<br>
   ].<br>
   ^self error:&#39;MyLibrary is not installed&#39;<br>
 ].<br>
<br>
etc.<br>
</blockquote>
Interesting. I thought the module in an FFI function declaration needed to be a literal string. How would you declare it to use MyLibrary instead?<br>
</blockquote>
<br>
Define it in a subclass of ExternalLibrary. Functions defined in a subclass of ExternalLibrary without a module: string use the moduleName from the time the library is instantiated. The module: string was really only intended for convenience such that one could declare FFI functions where it is most convenient instead of having to use ExternalLibrary subclasses.<br>


<br>
</blockquote>
<br></div></div>
That&#39;s a useful trick, thanks. Have not ever seen it before.<br><font color="#888888">
<br>
<br>
- Bert -<br>
<br>
<br>
<br>
</font></blockquote></div><br>