SQLite User Forum

sqlite3 3.49.0 mingw build libsqlite3.lib instead of libsqlite3.a
Login

sqlite3 3.49.0 mingw build libsqlite3.lib instead of libsqlite3.a

(1.1) By Mark Brand (mabrand) on 2025-02-07 10:26:25 edited from 1.0 [source]

I just noticed that since version 3.4.9, the library built for the MinGW target is named libsqlite3.lib instead of the expected libsqlite3.a.

My understanding is that .lib is used by the MSVC compiler, whereas the MinGW convention is .a.

For the build for MXE https://mxe.cc/, I fixed the problem with this patch:

+diff --git a/autosetup/proj.tcl b/autosetup/proj.tcl
+index 1111111..2222222 100644
+--- a/autosetup/proj.tcl
++++ b/autosetup/proj.tcl
+@@ -787,7 +787,7 @@ proc proj-lib-extension {} {
+   proc inner {key} {
+     switch -glob -- [get-define $key] {
+       *-*-ming* - *-*-cygwin - *-*-msys {
+-        return ".lib"
++        return ".a"
+       }
+       default {
+         return ".a"

(2) By Stephan Beal (stephan) on 2025-02-07 11:33:50 in reply to 1.1 [link] [source]

I just noticed that since version 3.4.9, the library built for the MinGW target is named libsqlite3.lib instead of the expected libsqlite3.a.

It's actually been that way since 3.48.0, Specifically, since November 6, 2024.

My understanding is that .lib is used by the MSVC compiler, whereas the MinGW convention is .a.

i'm hesitant to make this change because we've had a frequent msys/cygwin user vetting the new build since October or November and they've never suggested this change was necessary. If you can get agreement from Jose C., or anyone else who frequently uses those platforms, or provide equivalent testimony/citations, i'll be convinced.

(3.2) By Mark Brand (mabrand) on 2025-02-07 12:09:15 edited from 3.1 in reply to 2 [link] [source]

One reason I did not notice the problem in 3.48 is that I had a leftover libsqlite3.a file from the previous version, which my applications were still linking to. The installed libsqlite3.lib from 3.48 was just ignored. I imagine I am not the only one.

Here is a discussion and persuasive answer on the library naming convention question:

https://stackoverflow.com/questions/43311621/c-correct-way-to-statically-dynamically-link-with-mingw-w64

(4) By Stephan Beal (stephan) on 2025-02-07 12:59:56 in reply to 3.2 [link] [source]

Here is a discussion and persuasive answer on the library naming convention question:

Fair enough! That's now changed in the trunk and the 3.49 branch. Thank you for the report and reference link.

(5.1) By Feng Yu (abcfy2) on 2025-02-08 15:43:23 edited from 5.0 in reply to 2 [link] [source]

Same issue here, my CI was breaked down: https://github.com/abcfy2/aria2-static-build/actions/runs/13210850254/job/36883848414

I use this toolchain for cross compile: https://github.com/musl-cross/musl-cross

But I have another issue:

Using tclsh: /usr/bin/tclsh8.6

    WARNING: Cannot find a usable tclConfig.sh file.  Use
    --with-tcl=DIR to specify a directory where tclConfig.sh can be
    found.  SQLite does not use TCL internally, but some optional
    components require TCL, including tests and sqlite3_analyzer.

Checking for TCL to use for code generation... 
Checking for dirent.h...ok
Checking for sys/time.h...ok
Checking for realpath...ok
TCL for code generation: jimsh
Support threadsafe operation? yes
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
Error: dlopen() not found. Use --disable-load-extension to bypass this check.
Checking libs for dlopen...no
Try: 'configure --help' for options

I have to add --disable-load-extension to fix this configure error. But before 3.47.0 it's working, no need to add --disable-load-extension, what happened ?

Also I have to add a soft link libsqlite3.a -> libsqlite3.lib to resolve this error:

strptime.c: In function '_strptime':
strptime.c:412:13: warning: 'tzname' is deprecated: Only provided for source compatibility; this variable might not always be accurate when linking to UCRT. [-Wdeprecated-declarations]
  412 |             else if (0 == strcmp(zonestr, tzname[0])) {
      |             ^~~~
In file included from localtime_r.h:43,
                 from strptime.c:38:
/cross_root/bin/../x86_64-w64-mingw32/sysroot/mingw/include/time.h:283:24: note: declared here
  283 |   _CRTIMP extern char *tzname[2] __MINGW_ATTRIB_DEPRECATED_UCRT;
      |                        ^~~~~~
strptime.c:415:13: warning: 'tzname' is deprecated: Only provided for source compatibility; this variable might not always be accurate when linking to UCRT. [-Wdeprecated-declarations]
  415 |             else if (0 == strcmp(zonestr, tzname[1])) {
      |             ^~~~
/cross_root/bin/../x86_64-w64-mingw32/sysroot/mingw/include/time.h:283:24: note: declared here
  283 |   _CRTIMP extern char *tzname[2] __MINGW_ATTRIB_DEPRECATED_UCRT;
      |                        ^~~~~~
  CXX      daemon.lo
  CXXLD    libaria2.la
  CXXLD    aria2c.exe
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.bfd: cannot find -lsqlite3: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:2157: aria2c.exe] Error 1
make[3]: Leaving directory '/usr/src/aria2-master/src'
make[2]: *** [Makefile:2679: all-recursive] Error 1
make[2]: Leaving directory '/usr/src/aria2-master/src'
make[1]: *** [Makefile:557: all-recursive] Error 1
make[1]: Leaving directory '/usr/src/aria2-master'
make: *** [Makefile:468: all] Error 2

Thanks

(6) By Stephan Beal (stephan) on 2025-02-08 16:42:32 in reply to 5.1 [link] [source]

I have to add --disable-load-extension to fix this configure error. But before 3.47.0 it's working, no need to add --disable-load-extension, what happened ?

A "managerial decision" happened during the port. It used to quietly disable that feature if no dlopen was found and now that's treated as an error. Though i personally consider that to be the correct behavior for that particular feature, arguments to the contrary will certainly be considered.

Sidebar: during initial development of the build port, during which time that change was made, no platform was readily available to me which didn't have dlopen, so this particular case never came up. Today i learned that there actually is such a platform.

Also I have to add a soft link libsqlite3.a -> libsqlite3.lib to resolve this error:

The .lib extension has, in the meantime, been changed to .a for msys/mingw/cygwin in the current trunk and 3.49 branch, so the next release will contain that change.

strptime.c: In function '_strptime':

For completeness's sake i'll point out to those concerned about the strptime.c/tzname warnings: those are coming from Feng Yu's source tree, not this one.

(7) By Mark Brand (mabrand) on 2025-02-10 07:47:43 in reply to 5.1 [link] [source]

Just want to point out that you can build sqlite in mingw without the --disable-load-extension if you have the prerequisite dlfcn-win32 package, which provides dlopen (https://github.com/dlfcn-win32/dlfcn-win32).

In the cross compiler environment MXE, we have added dlfcn-win32 to the dependency list of sqlite (https://mxe.cc/) to address this.

(8) By Stephan Beal (stephan) on 2025-02-10 15:04:54 in reply to 6 [link] [source]

A "managerial decision" happened during the port. It used to quietly disable that feature if no dlopen was found and now that's treated as an error.

That decision has, after consultation with the team, been reverted. Lack of dlopen() now emits a warning unless --enable-load-extension is used, in which case lack of dlopen() is fatal. That change is now in the trunk and the 3.49 branch.