SQLite Forum

C api sqlite3_db_readonly returns -1
If that compile/link invocation ran without errors, I see no likelihood that your seg-fault was due to use of whatever pre-built sqlite3.o got linked that way. So, remotely possible, but not worth any investigation IMO.

FWIW, the code I posted (compiles and) runs without any seg-fault and yields expected results.

Given your platform and perhaps recently begun use of C, I recommend learning to use gdb. You can tell it to start with a core dump and then see what went wrong, at least in its latter stages. The SQLite debug build, used with a debug build of your own code, will make the debugging experience much more useful.