m4heshd / better-sqlite3-multiple-ciphers

better-sqlite3 with multiple-cipher encryption support 🔒
MIT License
140 stars 27 forks source link

Error building custom configuration #45

Closed tmpit closed 1 year ago

tmpit commented 1 year ago

Hello, I need to be able to pass URI parameters when opening a database file, so I'm trying to build a custom version of sqlite with SQLITE_USE_URI=1. I'm following your guide for a custom configuration. I downloaded the 3.41.1 amalgamation. After running

npm install better-sqlite3-multiple-ciphers --build-from-source --sqlite3=/path/to/sqlite-amalgamation 

compilation fails with the following errors:

npm ERR! ./src/objects/database.lzz:229:30: error: use of undeclared identifier 'sqlite3_key'
npm ERR!                 int status = sqlite3_key(db_handle, buffer, len);
npm ERR!                              ^
npm ERR! ./src/objects/database.lzz:248:30: error: use of undeclared identifier 'sqlite3_rekey'; did you mean 'sqlite3_trace'?
npm ERR!                 int status = sqlite3_rekey(db_handle, buffer, len);
npm ERR!                              ^~~~~~~~~~~~~
npm ERR!                              sqlite3_trace
npm ERR! ./Release/obj/gen/sqlite3/sqlite3.h:3264:36: note: 'sqlite3_trace' declared here
npm ERR! SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,
npm ERR!                                    ^
npm ERR! ./src/objects/database.lzz:248:55: error: cannot initialize a parameter of type 'void (*)(void *, const char *)' with an lvalue of type 'char *'
npm ERR!                 int status = sqlite3_rekey(db_handle, buffer, len);

Is there something I'm doing wrong?

This is my envrionment

m4heshd commented 1 year ago

Hi @tmpit,

Unfortunately, you cannot build the vanilla amalgamation with this build configuration. You can do that using the upstream package (better-sqlite3).

tmpit commented 1 year ago

Thank you for the response. The upstream package doesn't work for me, because I need an encrypted database. Could you provide some guidance on how I can make this work If I fork this project? Would it be enough if I change the options in the deps/defines.gypi and then rebuild?

m4heshd commented 1 year ago

If you're willing to use the provided amalgamation, yes, adding your compile-time options to defines.gypi would do. But that won't guarantee a successful build. Some compile-time options mess a lot with this extension. You're just gonna have to try it and test it.

tmpit commented 1 year ago

Alright, thanks!