Skip to content

Database#load_extensions is not enabled on Windows when using native gems or compiling vendored source code (sqlite 3.48.0+) #618

Open
@flavorjones

Description

@flavorjones

Summary

Loading extensions is not available on Windows when using the precompiled native gems or compiling the vendored sqlite library from source, starting with sqlite3-ruby v2.6.0.

We are asking for help from Windows users who want or need this feature.

Context

Sqlite 3.48.0 and later have dramatically changed the "autoconf amalgamation" that is vendored in
this gem. Specifically, the configuration is no longer actually autoconf, but some scripts that
emulate autoconf's interface and behavior.

Although this mostly "just worked", we're having a problem resolving the libraries necessary for
loading extensions. As a result, starting with sqlite3-ruby v2.6.0, extensions cannot be loaded on Windows when using precompiled native gems or when compiling the vendored sqlite library.

Workarounds

If you are a Windows user and need to load extensions, you have options.

  1. use a version of sqlite3-ruby < 2.6.0
  2. compile from source, and link against a system sqlite library (not the vendored version). See https://github.com/sparklemotion/sqlite3-ruby/blob/main/INSTALLATION.md#avoiding-the-precompiled-native-gem for help doing this.

Request

If you are a windows user, and you want or need this feature, we need your help.

  • If you can figure out how to make this build properly, please comment below, I'd like to work with you to update this gem's extconf.rb to link properly.
  • If you know a lot about the Windows runner for Github Actions, or about how setup-ruby configures the runner, then please think and/or comment to let me know what I should be trying.

I have not started a thread in the upstream forum because I'm pretty sure this can be solved with the right set of configure options/compiler flags/linker flags, I just can't figure out what that combination is and I can't afford to spend more time on it right now.

Details

A good example of the failure in question is here: https://github.com/sparklemotion/sqlite3-ruby/actions/runs/13420426491/job/37491733507#step:5:368

Here's the full log: 44_test (windows, 3.4, disable).txt

Some of the relevant snippets from that log:

Configuring SQLite version 3.49.1
Warning: Failed to find x86_64-w64-mingw32-ld, falling back to ld which may be incorrect
Warning: Failed to find x86_64-w64-mingw32-ar, falling back to ar which may be incorrect
Looking for install ... c:/msys64/usr/bin/install
Checking for int8_t...ok
Checking for int16_t...ok
Checking for int32_t...ok
Checking for int64_t...ok
Checking for intptr_t...ok
Checking for uint8_t...ok
Checking for uint16_t...ok
Checking for uint32_t...ok
Checking for uint[64](https://github.com/sparklemotion/sqlite3-ruby/actions/runs/13420426491/job/37491733507#step:5:65)_t...ok
Checking for uintptr_t...ok
Checking for gmtime_r...not found
Checking for isnan...ok
Checking for localtime_r...not found
Checking for localtime_s...not found
Checking for malloc_usable_size...not found
Checking for strchrnul...not found
Checking for usleep...ok
Checking for utime...ok
Checking for pread...not found
Checking for pread64...not found
Checking for pwrite...not found
Checking for pwrite64...not found
Checking libs for fdatasync...no
Checking libs for nanosleep...none needed
Checking for sys/types.h...ok
Checking for sys/stat.h...ok
Checking for dlfcn.h...not found
Checking for unistd.h...ok
Checking for stdlib.h...(cached) ok
Checking for malloc.h...ok
Checking for memory.h...ok
Checking for string.h...ok
Checking for strings.h...ok
Checking for inttypes.h...ok
Checking for zlib.h...ok
Checking libs for deflate...-lz
Checking whether the C compiler accepts -rpath C:/hostedtoolcache/windows/Ruby/3.4.2/x64/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.test.2025.0219.1912/ports/x[86](https://github.com/sparklemotion/sqlite3-ruby/actions/runs/13420426491/job/37491733507#step:5:87)_64-w64-mingw32/sqlite3/3.49.1/lib...no
Checking whether the C compiler accepts -Wl,-rpath,C:/hostedtoolcache/windows/Ruby/3.4.2/x64/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.test.2025.0219.1[91](https://github.com/sparklemotion/sqlite3-ruby/actions/runs/13420426491/job/37491733507#step:5:92)2/ports/x86_64-w64-mingw32/sqlite3/3.49.1/lib...yes
SQLITE_DEBUG build? no
Support threadsafe operation? Checking for libs...
Checking libs for pthread_create...none needed
Checking libs for pthread_mutexattr_init...none needed
Checking for line-editing capability...
WARNING: Skipping check for readline.h because we're cross-compiling.
Line-editing support for the sqlite3 shell: none
Checking libs for dlopen...no

    --enable-load-extension was provided but dlopen()
    not found. Use --disable-load-extension to bypass this
    check.

and

============
Failed: gcc -fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1 conftest__.c -o conftest__
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\RUNNER~1\AppData\Local\Temp\ccAsr52L.o:conftest__.c:(.text.startup+0xa): undefined reference to `dlopen'
collect2.exe: error: ld returned 1 exit status
child process exited abnormally
============
The failed code was:
extern void dlopen(void);
int main(void) {
dlopen();
return 0;
}
============
Failed: gcc -fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1 conftest__.c -o conftest__ -ldl
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldl: No such file or directory
collect2.exe: error: ld returned 1 exit status
child process exited abnormally
============
The failed code was:
extern void dlopen(void);
int main(void) {
dlopen();
return 0;
}
============

Relevant configure scripts are in https://github.com/sqlite/sqlite/tree/master/autosetup

cc @larskanis in case you have any ideas

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions