<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>Holà Juan et al.,<div><br></div><div>So, I put the attached dylib in the Resources folder of the Squeak-jit VM (like always), then I fired up a fresh 5772 image and loaded the FFI and FFI-Test packages, and filed in the attached ST code (PortMIDILibrary class).</div><div><br></div><div>(I checked and the dylib exports a code token named “pm_count_devices” (try <b style="font-family: "Courier New"; font-size: 14px;">nm -ng libportmidi.dylib | grep pm_</b><b style="font-family: "Courier New"; font-size: 13px;"> </b>))</div><div><br></div><div>These tests worked:</div><div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>FFITestLibrary ffiTestInt: $A asCharacter with: 65 with: 65.0 with: true.</font></div><div><font face="Helvetica"><br></font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>FFITestLibrary new ffiPrintString:'Hello World!!' asUtf8BytesOrByteString.</font></div><div><font face="Helvetica"><br></font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>FFIPluginTests new testBiggerStruct</font></div><div><font face="Helvetica"><br></font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>FFIPluginTests new testConstructedPrintString</font></div><div><br></div><div>and this returned a nice string</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>FFITestLibrary moduleName</font></div><div><br></div><div>and this returned the expected lib name</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>PortMIDILibrary moduleName</font></div><div><br></div><div>But trying to call a simple prim like</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>PortMIDILibrary pm_count_devices</font></div><div><br></div><div>failed, not being able to locate the C fcn. All that the method does is,</div><div><br></div><div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>pm_count_devices</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>"Answer the number of MIDI ports"</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>"PortMIDILibrary pm_count_devices”</font></div><div><font face="Helvetica"><br></font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>< cdecl: long 'pm_count_devices' (void) module: 'libportmidi.dylib' ></font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>^self externalCallFailed</font></div></div><div><br></div><div><br></div><div>So I tried the lower-level way, as in,</div><div><br></div><div>Works</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>[ExternalAddress loadSymbol: 'ffiTestFloats' asUtf8BytesOrByteString </font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>module: FFITestLibrary moduleName asUtf8BytesOrByteString]</font></div><div><br></div><div>Doesn’t work</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>[ExternalAddress loadSymbol: 'pm_count_devices' asUtf8BytesOrByteString </font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>module: PortMIDILibrary moduleName asUtf8BytesOrByteString]</font></div><div><br></div><div>All variations of this return a function with address 0</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>[ExternalLibraryFunction</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>name: 'pm_count_devices' asUtf8BytesOrByteString</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>module: ‘libportmidi.dylib' asUtf8BytesOrByteString</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>callType: 0 </font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>returnType: ExternalType long</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>argumentTypes: ((1 to: 1) collect: [ :i | ExternalType void])]</font></div><div><br></div><div>And this fails, of course</div><div><br></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>[ | meth |</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>meth := ExternalLibraryFunction</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>name: 'pm_count_devices' asUtf8BytesOrByteString</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>module: 'libportmidi' asUtf8BytesOrByteString</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>callType: 0 </font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>returnType: ExternalType long</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>argumentTypes: ((1 to: 1) collect: [ :i | ExternalType void]).</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>result := meth invoke.</font></div><div><font face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span>result]</font></div><div><br></div><div><br></div><div>Is there something obvious that I’m doing wrong?</div><div>I’m running on an ARM-based MacStudio.</div><div>The prims work fine with Squeak and the Squeak6.1alpha VM.</div><div><br></div><div>…any reply MOST appreciated…</div><div><br></div><div>stp</div><div><br></div><div>——</div><div><br></div><div>Attachments</div><div><br></div><div>Minimal ST class w prim interface</div><div><br></div><div></div></div></body></html>