[squeak-dev] SQLite in Squeak Smalltalk

Bert Freudenberg bert at freudenbergs.de
Fri Feb 10 10:31:01 UTC 2017


On Fri, Feb 10, 2017 at 5:05 AM, Edwin Ancaer <eancaer at gmail.com> wrote:

> Ben, Vaidotas,
>
> thanks for helping me out. The version at http://smalltalkhub.com/#!/
> ~MilanVavra/SqueakSQLite3
> is working, but only after I added the module: parameter in the api...
> method definitions in the class, eg.
>
> <cdecl: long 'sqlite3_open' (char* SqliteReference*) *module:
> 'libsqlite3.so.0'*>
>
> I found the module: parameter http://wiki.squeak.org/squeak/2426.
> Is this new for FFI in Squeak 5, or is there still something wrong with my
> FFI settings?
>

I guess it would work if you symlink *libsqlite3.so.0 *to *libsqlite3.so*,
either manually or by installing the *sqlite3-dev* package. Alternatively,
change SqliteLibrary class>>moduleName to return '*libsqlite3.so.0*'.

All FFI functions in an ExternalLibrary subclass share the class's
moduleName, instead of having to declare it in every method. SqliteLibrary
is an ExternalLibrary subclass, and it declares its moduleName
as 'sqlite3'. That should work, since the VM adds a 'lib' prefix and a
'.so' suffix (see sqUnixExternalPrims.c).

The way other FFI libraries handle this is by making the moduleName method
answer different names for each platform. E.g. Nicolas' Smallapack library
does this:

moduleName
"Return the name of the module for this library
this should depend on host machine"
moduleName ifNil:
[moduleName := self isUnix
ifTrue: [self unixModuleName]
ifFalse: [self isMacOS
ifTrue: [self macOsxModuleName]
ifFalse: [self win32ModuleName]].
self new forceLoading].
^moduleName

unixModuleName
<preference: 'The name of the FORTRAN Lapack library on Unix'
category: 'Smallapack'
description: 'Check for existing liblapack-dev package.'
type: #String>
^unixModuleName ifNil: [ 'liblapack.so' ]

... which allows you to change the library name as a preference. (it also
mentions the liblapack-dev package, which provides the .so symlink)

- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170210/b4bce89e/attachment.html>


More information about the Squeak-dev mailing list