I use a statically linked library for Sqlite in an iPhone Xcode project. I am now trying to include a .C extension to Sqlite in this project. However, I am having trouble making the Sqlite in the build SEE the extension.
The statically linked Sqlite library works fine. Also the .C extension works on my desktop, and builds fine as a statically linked library in Xcode. However, the custom functions it defines are missing when called.
For example, I load the extension as so with no errors.
SELECT load_extension('extension_name.so');
But when I try to call a function defined in the extension, I get this message
DB Error: 1 "no such function: custom_function"
Does anyone know much about linking a Sqlite extension into an Xcode project?
As said by @jbworld you cannot load dynamic libraries on the iPhone, so this link should be made statically, at compilation time. While reading at the code of spatialite (that’s an SQLite extension), I found that kind of invocation:
And the
init_static_spatialitecode:So it looks like if the
sqlite_auto_extensionenables you to statically link an extension. The documentation seems to confirm that:Then, at runtime, for spatialite, I just have to invoke the
spatialite_init(0)to get the extension up and running.Invoke such method before loading any sqlite DB.
Hope this helps.