asg017 / sqlite-regex

A fast regular expression SQLite extension, written in Rust
Apache License 2.0
166 stars 7 forks source link

Error on V0.2.0 for MacOS x86 precompiled lib #6

Closed chrsstrm closed 1 year ago

chrsstrm commented 1 year ago

Hello. I tried to load the current (V0.2.0) pre-compiled MacOS x86 lib and received the following error:

Error: dlsym(0x20ee33760, sqlite3_regexp_init): symbol not found    

I thought this might be due to the version of Sqlite I was using (3.36) so I updated to 3.41 and the error persisted.
I then downgraded the regexp0.dylib to V0.1.0 and it loads just fine.
It appears this issue was introduced in the new build.

I did not attempt to compile the V0.2.0 version myself, but I would appreciate some instructions included in the docs on how to do so.
Thanks.

hyyl35 commented 1 year ago

I've the same error on arm macos

asg017 commented 1 year ago

Thanks for filing!

By any chance, is your extension named regexp0.dylib instead of regex0.dylib (without the p)? It should be named regex0.dylib, since SQLite will infer the entrypoint based on the filename (which is sqlite3_regex_init).

Based on your error message, my guess is that when you downloaded the extension you re-named it to regexp0.dylib instead of regex0.dylib. I'll change the release assets to a .tar.gz archive with regex0.dylib inside, so that you don't have to download + rename yourself. I've done this with other extensions like sqlite-ulid, just haven't updated sqlite-regex yet.

Also to note: sqlite-regex is different from the regexp extension that the SQLite team offers, and different from the sqlean regexp extension. Both of those use regexp.dylib (with the p), while sqlite-regex uses regex0.dylib (without the p, and with 0 as a major version designated). Very fun!

Re instructions to compile yourself: I will add this! For reference you can git clone the repo and run make loadable, and the compiled extension will appear in dist/debug/regex0.dylib (assuming you have rust + c compiler installled).

Let me know if that works! Apologies for the confusion.

greatvovan commented 1 year ago

Thank you @asg017, renaming to regex0.dylib helped.

In CLI we can also specify .load ./macos-x86_64-regex0 sqlite3_regex_init so it will work without renaming,

chrsstrm commented 1 year ago

@asg017 the naming issue was the problem.
I was using the regex package from the SQLite team and also loading extensions with a .sqliterc file. I had renamed the sqlite-regex binary to match what was referenced in my .sqliterc to make it drop-in compatible with my setup and that was the problem. Thanks for clarifying.

greatvovan commented 1 year ago

regex package from the SQLite team

Sorry @chrsstrm, what does that mean?

chrsstrm commented 1 year ago

@greatvovan maybe my wording wasn't quite correct. I'm not sure that it is "from" the SQLite team but I compiled and used an extension found on the official SQLite site here https://sqlite.org/src/file?name=ext/misc/regexp.c

greatvovan commented 1 year ago

Thanks @chrsstrm. What platform are you using? If Linux/Mac, can you share the compile command?

chrsstrm commented 1 year ago

@greatvovan this was on a Mac.
It was a while ago so I had to go back into my notes, but looks like this was the compile command that worked for me:

gcc -I /usr/local/opt/sqlite/include -fPIC -dynamiclib regexp.c -o regexp.dylib

My SQLite was installed with brew so that's why the needed header files live in that path, adjust yours as needed.